Commit Graph
8 Commits
Author SHA1 Message Date
Behdad Esfahbod 036a5ad86f [gpu] Add font feature support to demo
- demo_buffer_set_features() sets global features for hb_shape
- web_set_features() wasm export parses comma-separated features
- Shell message handler accepts { kind: "features", value }
- Features applied to all shape calls in demo_buffer_add_text

Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 20:05:43 -06:00
Behdad Esfahbod c86cb51bf6 [gpu] Fix garbled rendering after font change in web demo
The GL renderer cached the vertex buffer upload by comparing
the data pointer and count.  After clearing and refilling the
buffer with a new font's glyphs, std::vector reused the same
allocation, so the pointer and count matched — the upload was
skipped and the GPU drew with stale vertex data containing old
atlas offsets.

Fix by adding a generation counter to demo_buffer_t that
increments on clear().  The renderer compares generation and
count to decide whether to re-upload.

Assisted-by: Claude <noreply@anthropic.com>
2026-04-01 23:25:48 -06:00
Behdad EsfahbodandClaude Opus 4.6 67528cdab3 [gpu] Remove dead GL code from demo_buffer_t
Drawing is now handled by the renderer, so demo_buffer_t no longer
needs its own VAO/VBO or demo_buffer_draw(). The buffer is now a
pure vertex data container.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 14:01:27 -06:00
Behdad EsfahbodandClaude Opus 4.6 6910b9a3ed [gpu] Add Metal backend for macOS demo
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>
2026-03-29 13:36:28 -06:00
Behdad Esfahbod f7d154bc97 Revert "[gpu] Right-align RTL lines to average width"
This reverts commit d87651e02fe44afcb57974b8f807d26462c7469c.
2026-03-28 12:56:20 -06:00
Behdad EsfahbodandClaude Opus 4.6 a41f194bef [gpu] Right-align RTL lines to average width
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>
2026-03-28 12:54:26 -06:00
Behdad EsfahbodandClaude Opus 4.6 25e69d9b96 [gpu] Port hb-gpu-demo to options.hh infrastructure
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>
2026-03-27 16:34:04 -06:00
Behdad EsfahbodandClaude Opus 4.6 03c2688436 [gpu] Add GPU demo app in util/gpu
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>
2026-03-26 18:30:13 -06:00