Bring hb_gpu_draw_encode into line with the rest of the render APIs:
auto-clear on success, and return the computed glyph extents to the
caller via a new out-parameter (nullable).
HB_EXTERN hb_blob_t *
hb_gpu_draw_encode (hb_gpu_draw_t *draw,
hb_glyph_extents_t *extents);
Consumers typically need both the encoded blob and the glyph's
extents to size the quad they'll draw into in the vertex shader;
returning them together removes a redundant trip through the draw
state and lets encode() auto-clear like hb_vector_*_render() and
hb_raster_*_render() do.
Drop hb_gpu_draw_get_extents() from the public API — its only
role was reading extents out of the draw state post-encode, which
the new encode() signature makes redundant. The computation
stays (moved to a static _hb_gpu_draw_get_extents helper) so
encode() can call it before auto-clear wipes the state.
ABI break for anyone who had already wired up against the 14.0.0
hb_gpu_draw_encode signature or hb_gpu_draw_get_extents, but the
library is new/experimental and the two in-tree consumers
(test/api/test-gpu.cc, util/gpu/demo-font.cc, util/hb-gpu-encode-all.cc,
test/fuzzing/hb-gpu-fuzzer.cc) are updated here.
All 240 tests pass.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Default hb_vector_{draw,paint}_t::format to HB_VECTOR_FORMAT_INVALID
instead of HB_VECTOR_FORMAT_SVG.
- Update renamed hb_vector_{draw,paint}_set_{flat,precision} API docs
from "Since: 13.0.0" to "XSince: REPLACEME".
- Extract hb_vector_draw_render_svg() helper to match the
hb_vector_draw_render_pdf() pattern; move the misplaced
hb_vector_draw_render doc comment to the actual function and update
it to say "output blob" since the renderer is no longer SVG-only.
- Revert 14.0.0 NEWS entry edits; the API rename will be announced in
the next release entry.
- Update docs/harfbuzz-sections.txt to reflect the API renames.
- hb-vector tool: expose -O/--output-format with supported formats
"svg/pdf", validate format, update description string, and switch
PDF detection to g_ascii_strcasecmp for case-insensitive matching.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When in fullscreen mode, pressing Escape now exits fullscreen
instead of closing the application. Pressing Escape again (or Q
at any time) still quits.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Drop "svg" from the names since flat/precision settings apply
equally to PDF output. The new names follow the hb_vector_draw_*
/ hb_vector_paint_* convention:
hb_vector_svg_set_flat -> hb_vector_draw_set_flat
hb_vector_svg_set_precision -> hb_vector_draw_set_precision
hb_vector_svg_paint_set_flat -> hb_vector_paint_set_flat
hb_vector_svg_paint_set_precision -> hb_vector_paint_set_precision
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add hb-vector-pdf-paint.cc with a complete set of PDF paint
callbacks for the HarfBuzz paint API:
push/pop_transform → q + cm / Q
push/pop_clip_glyph → q + path + W n / Q
push/pop_clip_rect → q + re + W n / Q
color → rg + re + f
push/pop_group → q / Q
gradients → solid fallback (first stop color)
The PDF paint backend reuses the draw funcs for glyph clip
path emission and shares the hb_vector_paint_t struct with
the SVG backend via hb-vector-paint.hh.
hb_vector_paint_glyph dispatches to SVG or PDF paint funcs
based on format. hb_vector_paint_render delegates to the
PDF render function for PDF output.
Tested with COLRv0 (RocherColorGX) — color layers render
correctly with proper clipping.
Assisted-by: Claude <noreply@anthropic.com>
Add HB_VECTOR_FORMAT_PDF to hb_vector_format_t. The hb-vector
tool now produces self-contained PDF when invoked with -o out.pdf.
PDF path operators map directly from the draw callbacks:
move_to → m, line_to → l, cubic_to → c, close_path → h,
with quadratic-to-cubic promotion (PDF has no Q operator).
The render function builds a minimal PDF 1.4 with catalog,
page, and content stream objects plus a cross-reference table.
Implementation:
- Extract hb_vector_draw_t struct to hb-vector-draw.hh so
future backends can share it.
- Draw callbacks branch on format for SVG vs PDF syntax.
- hb_vector_draw_glyph and hb_vector_draw_render dispatch by
format.
- vector-output.hh selects format from file extension and
skips paint (color glyphs) for PDF.
Coordinate system needs refinement — the page layout inherits
the SVG Y-flip transform, placing glyphs at the top with
extra whitespace. Correct PDF coordinate handling is a
follow-up.
Assisted-by: Claude <noreply@anthropic.com>
Check navigator.gpu synchronously in main() before calling
the WebGPU C API. Previously the error was reported in an
async callback that raced with onRuntimeInitialized, which
hid the loading div before the error message could appear.
Also re-show the loading div and set window._webgpuError in
the adapter callback as a fallback.
Assisted-by: Claude <noreply@anthropic.com>
Add hb_gpu_draw_set_scale() API and store x/y scale in the
glyph blob header (buf[1].b/a). hb_gpu_draw_glyph() sets it
automatically from the font.
hb_gpu_render() now reads the scale, computes ppem via fwidth,
and automatically blends 4 corner samples at ±1/3 pixel when
ppem < 16 to reduce moiré at small sizes. Define
HB_GPU_NO_MSAA to disable.
Add hb_gpu_ppem() public shader helper so clients can get
ppem without touching internal functions (e.g. for
hb_gpu_darken).
Remove hb_gpu_render_aaa(), u_upem uniform, and set_upem
plumbing from the demo — no longer needed.
GLSL only for now.
Assisted-by: Claude <noreply@anthropic.com>
Replace the two-program MSAA toggle with hb_gpu_render_aaa()
that takes ppem from the caller and auto-selects single-sample
(ppem >= 16) or 4-corner MSAA (ppem < 16). This keeps
hb_gpu_render() lean for the fast path while letting the
adaptive function handle small sizes.
The previous approach had the ppem calculation inside the
library shader using 1/fwidth(texcoord), which was wrong by
a factor of upem — MSAA fired at all sizes. Now the demo
passes correct ppem via a u_upem uniform.
Remove the 'm' key toggle, two-program compilation, and
set_msaa plumbing — no longer needed.
GLSL only for now.
Assisted-by: Claude <noreply@anthropic.com>
The previous commit added the generation parameter to the
display interface but missed passing it from demo_view_display.
Assisted-by: Claude <noreply@anthropic.com>
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>
Add hb_gpu_render_msaa() that evaluates 9 samples (3x3 grid
at ±1/3 pixel) to reduce moiré at small sizes. GLSL only.
The demo compiles two shader programs and toggles between them
with the 'm' key, so the MSAA program's register pressure
does not affect the fast single-sample path.
Assisted-by: Claude <noreply@anthropic.com>
Implies --demo and --type '30=f ' (zoom 30x, fullscreen,
animate). Quits automatically after 3 fps reports.
Uses a GOption parse callback so --demo is set early enough
for the default font/text machinery.
Assisted-by: Claude <noreply@anthropic.com>
Allows simulating keyboard input at launch, e.g. -T '30= f'
zooms 30x, toggles fullscreen and starts animation.
Assisted-by: Claude <noreply@anthropic.com>
Add config.h with HB_LEAN and config-override.h to re-enable
draw, metrics, and variable font support. Strips color, paint,
math, bitmap, deprecated APIs, and other unused features.
WebGL: 635KB → 513KB (-19%)
WebGPU: 655KB → 533KB (-19%)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Library function for stem darkening: pow(2, brightness-0.5)
scaled by ppem. Added to GLSL, MSL, WGSL, HLSL with consistent
brief docs. Demo shaders now call the library function.
Section docs in hb-gpu.cc updated with usage example.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace boolean light_on_dark with continuous brightness-driven
exponent. pow(2, b-0.5) gives sqrt(2)≈1.414 for white text
(thin) and 1/sqrt(2)≈0.707 for black text (fatten), perfectly
symmetric around 1.0 at 50% gray.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The WebGPU touch path was still using the older gesture state machine.
It handled 3->2 reseeding, but it did not track whether a pinch was
active and it had no explicit 2->1 single-finger pan handoff.
Carry over the proven transition rules from the WebGL path without
changing desktop input handling: track pinch-active and synthetic
single-pan state, preserve the 3->2 reseed, and continue pan after a
pinch when one finger remains. touchcancel now also clears those touch
states consistently.
Testing:
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build.sh
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build-webgpu.sh
Assisted-by: OpenAI Codex
The previous fix stopped the 2->1 jump by swallowing the pinch-ending
touchend and seeding a synthetic left-button press at the remaining
finger. But subsequent one-finger motion was still left to the browser,
which does not reliably resume mouse emulation mid-gesture.
Track an explicit single-finger pan mode after the pinch handoff, route
its touchmove events to synthetic mousemove, and end it with a
gesture-cancelled synthetic mouseup on lift or touchcancel.
Testing:
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build.sh
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build-webgpu.sh
Assisted-by: OpenAI Codex
The WebGL touch path only tracked the initial 3->2 reseed with
skipNextPinchMove. Once a real pinch was underway, the later 2->1
transition stopped being treated as a gesture handoff and fell back
into the browser/GLFW single-touch path.
Track pinch-active state explicitly, swallow the pinch-ending touchend,
and hand single-finger pan off from the remaining touch by syncing the
cursor before synthesizing mousedown. This keeps the 3->2->1 sequence
from jumping the view when the second finger lifts.
Testing:
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build.sh
- source /home/behdad/emsdk/emsdk_env.sh >/dev/null &&
EM_CACHE=/tmp/emscripten-cache ./util/gpu/web/build-webgpu.sh
Assisted-by: OpenAI Codex
Dispatch mousemove before mousedown when transitioning from
pinch to single-finger pan, so GLFW's cursor position matches
the remaining finger.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
GPU library always builds (no deps). GPU demo controlled by
gpu_demo option (auto default). Only MSVC CI disables it
(GLEW wrap broken with -nodefaultlib). All other CIs install
GLEW/GLFW system packages.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Drop gpu_demo option. GLEW/GLFW use required:false — demo builds
when deps are found, skipped when not. Install GLEW/GLFW on all
CIs (Linux already had them, add to macOS and Rust). MinGW CI
uses wraps via --wrap-mode=default.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
GPU library is always built (no deps). GPU demo (hb-gpu) requires
GLEW/GLFW/GL and is controlled by gpu_demo option (auto by default).
When disabled, deps aren't even looked up — fixes MSVC pulling in
broken GLEW wrap. MinGW CI explicitly enables with -Dgpu_demo=enabled.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Wire demo_renderer_create_d3d11 into gpu-output.hh with --direct3d
flag. Add to meson build conditionally on Windows with d3d11 and
d3dcompiler libraries. Remove standalone D3D11 demo (superseded).
hb-gpu.exe --demo --direct3d now works under Wine.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add _USE_MATH_DEFINES before <cmath> includes on Windows.
hb-gpu.exe now cross-compiles successfully with MinGW.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implements demo_renderer_t using D3D11, same pattern as Metal.
Uses GLFW for windowing (GLFW_NO_API + glfwGetWin32Window).
Compiled conditionally with #ifdef _WIN32.
Not yet wired into gpu-output.hh or build system — needs
GLFW and GLib for MinGW, which are available on Fedora.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The tool now requires a font file argument by default, like
other hb-* tools. Pass --demo to use the built-in demo font
and text. --metal is now a proper GLib option instead of manual
argv parsing. Window title changed to "HarfBuzz GPU".
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Draw a semi-transparent fullscreen quad with the background color
each frame instead of clearing, so previous frames fade gradually.
Uses a tiny passthrough shader and attributeless triangle.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Skip glClear when trail is on — previous frames stay visible,
creating a paint/stamp effect during animation and interaction.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Double-left-click and double-right-click both reset view.
Middle-click reset also still works. Updated help text.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Second click within 300ms undoes the first click's animation
toggle and resets the view. Works across all backends.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
GLFW doesn't see the remaining finger after a swallowed pinch,
so synthesize a mousedown to start drag tracking.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>