Small finger movements (< 5 pixels) during a touch no longer
count as a drag, allowing tap-to-toggle-animation to work
reliably on touchscreens.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace **bold** markdown with plain text (unsupported by
GTK-Doc). Wrap multi-line code snippets in |[ ]| blocks
instead of backticks.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Web build using Emscripten + WebGL2 with HB_GPU_ATLAS_2D mode.
Touch support: drag to pan, tap to toggle animation.
FPS counter overlay. Viewport meta for mobile.
Fix cursor position on first touch by querying glfwGetCursorPos
in mouse_func. Left click/tap also toggles animation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The shader source is compatible with both GLSL 3.30 and
GLSL ES 3.00. Rename the enum value to reflect this and
match the type name convention.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When HB_GPU_ATLAS_2D is defined before including the fragment
shader source, the atlas switches from isamplerBuffer to
isampler2D with a width uniform. All texelFetch calls go
through _hb_gpu_fetch() which handles the 1D-to-2D coordinate
conversion.
The vertex shader works in both GLSL 330 and ES 300 as-is.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The leading-comment mechanism corrupted fuzzer font files by
prepending non-font data. Remove the function, its callers,
and strip the one seed file that had a leading comment.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Shaping is already exercised by the shape fuzzer. Simplify
the raster and vector fuzzers to just render gids 0..15
directly, matching the GPU fuzzer pattern.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pre-generate demo shader headers, default text, and default font
so the demo builds without stringize or hexify at compile time.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pre-generate hb-gpu-{fragment,vertex}-glsl.hh from the .glsl
sources so the library builds without Python/stringize at
compile time.
When stringize is found, a build rule regenerates them from
the .glsl sources and copies back to the source tree, matching
the ragel artifact pattern.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The large default text block looked too distorted with
perspective=4. Use 16 for a flatter initial view.
The user can still adjust with Shift+right-drag.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Change hb_gpu_shader_{fragment,vertex}_sources() (array + count)
to hb_gpu_shader_{fragment,vertex}_source() returning a single
const char *. Each language variant is one complete string.
Simplifies the demo shader compilation and documentation.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Document the full GPU rendering pipeline in the SECTION doc:
atlas setup, shader compilation, vertex attributes (position,
texcoord, normal, jac), hb_gpu_dilate usage, hb_gpu_render
usage, and typical vertex/fragment shader mains.
Note that this implements the Slug algorithm by Eric Lengyel.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the manual getopt-based demo main with the standard
main_font_text_t / shape_consumer_t composition, getting all
harfbuzz options for free: --variations, --features, --script,
--direction, --face-index, --font-funcs, etc.
New gpu_output_t (in util/gpu-output.hh) implements the output
interface, feeding shaped glyphs to the demo's GL renderer.
Add demo_buffer_add_glyph() and demo_buffer_current_line() to
demo-buffer for glyph-at-a-time insertion (vs the old batch
add_text which did its own shaping).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove stray "glyph" from doc comments where it referred to
the encoder rather than an actual glyph. Add typical usage
example to the SECTION doc block.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Encodes up to 16 glyphs per fuzzed font input, exercising
draw accumulation, cu2qu, encode, extents, and blob recycling.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
recycle_blob stores the blob; encode reuses both the blob object
and its data buffer when the buffer is >= needed and < 2x needed.
Otherwise malloc fresh and replace_buffer on the recycled blob.
hb_blob_t::replace_buffer now skips destroy_user_data when the
new data pointer is the same as the old one (same-buffer reuse).
Add explicit destructor to hb_gpu_draw_t for recycled_blob cleanup.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
shrink(0) frees the allocation; clear() keeps it. Avoids
re-allocation on every encode cycle.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Store blob offsets as value-32768 in the signed int16 texel
fields; the shader recovers with +32768. This doubles the
maximum blob size from 32767 to 65535 texels.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Cubics with collinear control points (common in CJK fonts)
caused cu2qu to subdivide to max depth, generating up to 1024
line segments per cubic. Detect the collinear case early
using cross-product distance and emit a single line instead.
Fixes encode failure for NotoSerifCJK gid 897 (48 cubics
were producing 24672 quadratics; now produces 48 lines).
Reduces total encode size for the font by ~34%.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Encodes all glyphs in a font, reports failures and summary
statistics (encoded/empty/failed counts, total and average sizes).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The old cmp_gids comparator produced descending order due to
hb_array_t::cmp's reversed memcmp argument order. This
happened to work with hb_qsort on Linux but broke with
std::sort on other platforms since bsearch expects ascending.
Switch to find_glyph_name(a).cmp(find_glyph_name(b)) > 0
which sorts ascending, matching what cmp_key expects.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All indices are guaranteed in-range by construction. Bypass
operator[] bounds checking for the hot encode loop.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
std::sort is not stable — when two gids have the same name,
their relative order was undefined, causing the wrong gid to
be found by binary search on some platforms.
Break ties with the gid value itself to make the order
deterministic.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Embed hb_gpu_encode_scratch_t in hb_gpu_draw_t with all the
temporary vectors the encoder needs. They persist across
encode calls and only grow, never shrink — eliminating
malloc/free overhead after the first glyph.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
hb_array_t::qsort(Compar) now uses std::sort for typed, inlineable
sorting. The no-arg qsort() uses priority dispatch: std::sort for
move-assignable types, hb_qsort fallback for packed OT structs
with deleted move ops.
hb_qsort itself is simplified to just forward to system qsort().
sort_r_simple is retained as fallback when qsort is unavailable.
Convert all direct hb_qsort callers to use typed array qsort with
lambdas. Remove dead comparator functions.
225 tests pass, 0 failures.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reduce to one templated hb_qsort, one templated qsort() on
hb_array_t/hb_vector_t, plus the no-arg qsort() that casts
Type::cmp to resolve ambiguity.
Convert all external call sites to lambdas so comparators
inline everywhere. Remove the void*-arg overload and the
plain function-pointer overload.
225 tests pass, 0 failures.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Make sort_r_simple and sort_r_cmpswap take the comparator as a
template parameter instead of a function pointer. This allows
lambdas and functors to inline into the sort, avoiding the
indirect-call overhead.
The function-pointer overloads remain for backward compatibility
and for the __OPTIMIZE_SIZE__ / qsort_r paths.
17% speedup on GPU encode benchmark (NotoSansCJK).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Three declarations in hb-gpu.h still had *glyph instead of *draw.
Add SECTION doc block in new hb-gpu.cc for gtk-doc.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add an hb_array_t::qsort overload that takes a comparator with a
void* context argument, forwarding to hb_qsort's existing qsort_r
support. Use it in the GPU encoder to eliminate the last std::
usage from library code.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use hb_min/hb_max instead of std::min/std::max, and
INT16_MIN/INT16_MAX instead of std::numeric_limits.
Only std::sort remains (needs lambda captures).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
INFINITY is float; assigning to double triggers -Wdouble-promotion.
HUGE_VAL is the double-precision infinity constant.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Allocate as hb_gpu_texel_t* directly instead of char* to avoid
an alignment-increasing cast.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The demo requires GLEW, GLFW3, and GL. Make these optional so the
library still builds on headless systems. The demo is skipped when
they're missing.
Install the GL packages in the Linux CI workflow so the demo
builds there.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The object is a draw_funcs_t closure, same role as hb_raster_draw_t.
Rename for consistency with the other modules.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move the executable definition to util/meson.build so the binary
lands at util/hb-gpu, consistent with other utilities.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
hb_object_destroy() already calls obj->~Type() for non-trivially-
destructible types, which runs hb_vector_t's destructor. The
explicit curves.fini() was freeing the array a second time.
Also remove encode_buf reuse — allocate fresh each encode call
and let the blob own the buffer via its destroy callback.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fall back to an embedded font when no font file is given,
matching the glyphy-demo behaviour.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port the glyphy-demo to use the hb-gpu API. Builds as util/hb-gpu
and requires GLEW, GLFW3, and OpenGL 3.3. Includes default text
and embedded font for quick testing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Port the glyphy library into harfbuzz as a new hb-gpu module,
following the hb-raster / hb-vector library pattern. The module
encodes glyph outlines into compact RGBA16I blobs for GPU rendering
using the Slug algorithm.
Fixes https://github.com/harfbuzz/harfbuzz/issues/5877
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>