Add MSL shader translations of the Slug GPU text rasterizer, and a
Metal rendering backend for hb-gpu-demo selectable via --metal flag.
Library changes:
- Add HB_GPU_SHADER_LANG_MSL enum value
- Add hb-gpu-vertex.msl and hb-gpu-fragment.msl
- Extend gen-gpu-shader-artifacts.py for MSL
Demo changes:
- Add demo-metal.h/mm with CAMetalLayer rendering
- Add external atlas backend for non-GL paths
- Add demo_buffer_get_vertices for Metal draw path
- Skip GL init when using Metal (GLFW_NO_API)
- Add --metal command-line flag
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a "text" button that opens a modal textarea with the current
text. Apply sends new text to WASM, flushing the glyph cache and
atlas. Custom text is preserved across font changes.
Also adds demo_font_clear_cache() and demo_atlas_clear() for
flushing state without full destroy/recreate.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Don't call demo_view_display from main() — let the main loop
handle the first frame. The premature call could render before
the browser's canvas was ready, and since it cleared needs_redraw,
no subsequent frame was drawn until user interaction.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a font button and drag-and-drop support to the web demo.
When a user provides their own .ttf/.otf font, the glyph cache
and atlas are flushed and the display is rebuilt with English-only
text (since the font may not support Persian).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a font button and drag-and-drop support to the web demo.
When a user provides their own .ttf/.otf font, the glyph cache
and atlas are flushed and the display is rebuilt with English-only
text (since the font may not support Persian).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Compute a and b from unshifted (raw int16 × power-of-2) coordinates
so they are exact, then pass renderCoord-shifted p1 separately as
the constant term. This eliminates float rounding residuals that
made a non-zero for true lines, removing the need for an epsilon
threshold in the linear fallback.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use 1.0/16384.0 instead of 1.0/65536.0 for detecting
near-degenerate quadratics in both horizontal and vertical
poly solvers, fixing rendering artifacts (thin white gaps)
at curve junctions caused by float rounding residuals in
the second-order coefficient.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
White-on-black with inverted gamma correction. Foreground
color passed as u_foreground uniform; background via
glClearColor. GL alpha blending preserved for glyph overlap.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Build the demo under HB_BUILD_UTILS when OpenGL, GLEW, and
GLFW3 are found. Remove hb-static.cc from gpu sources to
avoid duplicate symbols when linking static libraries.
Add 'gpu' to the hb-features.h generation loop.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Useful for profiling — run the encode loop multiple times
and report averaged timing.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Report outline, encode, and wall time with per-glyph rates.
Also restore max blob size reporting.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dependency('gl') resolves to Mesa's libGL via Homebrew, which
can't render to native macOS windows.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Detect RTL direction from shaped buffers and right-align those
lines in the demo. Uses the average width of RTL lines as the
alignment target for a balanced look.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Generate default-text-combined.hh with 35 lines of English +
35 lines of Persian for the web demo, matching the desktop
demo's adaptive line count.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the embedded default font with Parastoo-Regular subsetted
to just the characters in the English and Persian demo texts (28K).
Adaptive line count: 70 total lines divided equally among
supported scripts. A Latin-only font gets 70 lines of English;
a Latin+Arabic font gets 35 of each.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Check the font's GSUB table for Latin and Arabic script support.
Build default demo text from English (Lorem Ipsum) and Persian
paragraphs for supported scripts, cropped to 35 lines each.
Source paragraphs live in perf/texts/{en,fa}-paragraph.txt.
gen-default-texts.py wraps them at fixed width and generates
the .hh headers.
Web demo hardcodes both texts since the embedded font supports
both scripts.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reduces wasm size from 933K to 687K via size optimization
and link-time dead code elimination.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merge the .c and .h files into single .hh headers with
static inline functions. Eliminates the C/C++ linkage issue
and simplifies the web demo build to a single em++ call.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When GL_FRAMEBUFFER_SRGB is not available (e.g. WebGL2), fall
back to shader-based gamma correction (pow(coverage, gamma)).
Press 'g' to cycle: sRGB → gamma 2.2 → no correction.
Default tries sRGB, falls back to gamma 2.2 automatically.
Replaces the old 's' (sRGB toggle) key binding.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
A template-based amalgamation that includes all harfbuzz components
behind HB_HAS_* guards:
#define HB_HAS_SUBSET
#define HB_HAS_GPU
#include "harfbuzz-world.cc"
If HB_FEATURES_H is defined, includes that header for the defines.
HB_HAS_SUBSET selects harfbuzz-subset sources, otherwise core only.
Optional modules: HB_HAS_ICU, HB_HAS_CAIRO, HB_HAS_RASTER,
HB_HAS_VECTOR, HB_HAS_GPU.
Generated from meson source lists via gen-harfbuzz-world.py and
a .cc.in template. Committed artifact auto-regenerates like
harfbuzz.cc.
Also: add include guard to hb-zlib.cc (shared between raster
and vector, would cause duplicate symbols without it), and
remove .hh files from hb_gpu_sources list.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The demo headers are pre-generated and committed; the
custom_target generation was already removed but the empty
variable and its reference remained.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Make scroll zoom proportional to delta (pow(STEP, yoffset))
instead of fixed steps. Add JS pinch-to-zoom handler that
translates two-finger touch to wheel events with a dead zone
to prevent jitter.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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>