mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-19 05:51:05 +01:00
Two paint-encoder bugs and two demo-plumbing bugs together prevented end-to-end rendering. With all four fixed, BungeeTint and similar COLRv0 fonts now render through the GL demo in their proper palette colors. ### Paint encoder 1. hb-gpu-paint-fragment.glsl: the LAYER_SOLID op's payload is a blob-relative texel offset, but the shader was passing it to hb_gpu_draw() as-is -- which treats its argument as an absolute atlas offset. Add the glyph's `base` to the payload before the draw-coverage call so the sub-blob reference resolves inside the paint blob instead of elsewhere in the atlas. 2. hb-gpu-paint.cc push_clip_glyph callback: was resetting pending_palette_index to 0. But harfbuzz's COLRv0 paint emitter calls custom_palette_color BEFORE push_clip_glyph for each layer, so the index set by custom_palette_color was being clobbered before the color callback consumed it -- every layer ended up tagged palette_index=0. Leave pending_palette_index alone in push_clip_glyph. ### Demo plumbing 3. util/gpu/demo-glstate.cc: demo_glstate_create now glUseProgram's its program immediately. The palette uniform upload reads GL_CURRENT_PROGRAM, and glyph upload happens from demo_buffer_current_line() -- which runs before demo_view_setup() would have bound the program. Without this, glGetIntegerv returned 0 and the palette was never uploaded. 4. util/gpu/demo-font.cc: adds lazy demo_font_upload_palette() on first glyph request. Also tries both "hb_gpu_palette" and "hb_gpu_palette[0]" for the uniform lookup since drivers disagree. ### Bonus util/hb-gpu-encode-all.cc: reports paint-encoded and draw-fallback counts / sizes / timings separately so you can tell where time goes in mixed-content fonts. Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>