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>
Remove support for rendering glyphs whose source is the OpenType
SVG table, in both hb-raster and hb-vector. SVG is a large format
and our in-tree parser/renderer was half-finished; the complexity
was not justified by the partial coverage.
This is source-side only: hb-vector's SVG *output* backend (used
to serialize outline / COLR glyphs to SVG) is unaffected. Fonts
that have an SVG table will still load; glyphs served only by that
table will not render from these libraries.
hb-raster:
- Delete the hb-raster-svg-* file cluster (11 .cc/.hh files plus
hb-raster-svg.hh: parse, base, bbox, clip, color, defs,
defs-scan, fill, gradient, parse, render, use, context).
- Drop svg_glyph/svg_font/svg_palette state from
hb_raster_paint_t and the HB_PAINT_IMAGE_FORMAT_SVG branch in
the image callback.
- Drop hb_raster_paint_push_clip_path + hb_raster_svg_path_func_t
(only used from the SVG renderer).
- Drop zlib dependency (gzip decompression was only used for the
SVG table reader; libpng brings its own zlib linkage for PNGs).
hb-vector:
- Delete hb-vector-svg-subset.{cc,hh} (extracted font-SVG glyph
for embedding in SVG output).
- Remove the HB_TAG('s','v','g',' ') branch from the image paint
callback; PNG embedding remains.
- Drop svg_image tracking state from hb_vector_paint_t
(current_color_glyph_has_svg_image, current_svg_image_glyph,
current_face, svg_image_counter, subset_body_scratch).
- Simplify the color-glyph cache to store just def_id instead of
packed (def_id, image_like).
- Drop hb_svg_append_image_instance_translate.
Build wiring: src/meson.build, CMakeLists.txt, harfbuzz-world.cc
updated to match. Test suite: remove SVG-specific cases from
test/api/test-raster.cc and the handwriting-{svg,picosvg} vector
tests + expected fixtures.
~5700 LOC deleted, ~10 LOC added. Full test suite (240 tests)
passes.
Assisted-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
hb_gpu_draw_get_extents() cast rounded bounds to hb_position_t
before subtracting them. A fuzzed glyph outline with an extreme
negative bound could therefore overflow signed int arithmetic while
forming width or height.
Compute the rounded bounds in double, reject non-finite values, and
clamp the exported extents to hb_position_t before returning them.
Add an API regression that covers the OSS-Fuzz testcase through the
public GPU draw API.
Fixes: https://oss-fuzz.com/testcase-detail/5918954634936320
Tested: meson test -C build --print-errorlogs
Assisted-by: OpenAI Codex
hb_gpu_draw_encode() could allocate a fresh output buffer and then
return NULL before transferring ownership to a blob, leaking that
temporary buffer on late encode failures.
The recycled-blob growth path also tried hb_realloc() first and fell
back to hb_malloc() when that failed. Once the new buffer was committed
to the recycled blob, the old recycled buffer could be orphaned.
Free temporary buffers on the remaining late-failure exits and keep
the old recycled buffer alive until a replacement has been committed.
Tighten the GPU API recycle test to encode a larger second outline so
that reused-buffer growth stays covered.
Tested:
- meson test -C build
Assisted-by: OpenAI Codex <codex@openai.com>
Encode used adjacent endpoint equality to infer contour breaks, which
fails when two contours touch at the same point. Track contour starts
explicitly during accumulation instead, and use that flag when packing
shared endpoints.
Encode also rounded blob bounds to the nearest quarter unit. That can
shrink the encoded extents and clip coverage at glyph edges. Quantize
mins downward and maxes upward so the blob header always encloses the
actual geometry.
Add focused API tests for both regressions.
Testing:
- meson test -C build
Co-authored-by: OpenAI Codex <codex@openai.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>
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>
The raster SVG image callback assumes hb_raster_paint_glyph()
seeded svg_font/svg_glyph state before the paint protocol
reaches HB_PAINT_IMAGE_FORMAT_SVG. Clients can also call
hb_font_paint_glyph_or_fail() directly with
hb_raster_paint_get_funcs(), which leaves svg_font unset and
crashes in hb_raster_svg_render().
Return false when the callback is reached without that
wrapper-only state, and cover the direct API path with a
regression test.
Testing: CCACHE_DISABLE=1 meson test -C build
Fixes https://github.com/harfbuzz/harfbuzz/security/advisories/GHSA-ggh9-cgg2-r4vr
Assisted-by: OpenAI Codex <codex@openai.com>
The raster SVG path treated hb_ot_color_glyph_reference_svg()
blobs as plain XML, even though SVG table documents may
legally be gzip encoded. That caused hb-raster to reject
fonts that store compressed SVG documents.
Detect gzip payloads in the raster SVG renderer, reject
documents whose advertised uncompressed size exceeds
HB_SVG_MAX_DOCUMENT_SIZE, and inflate the rest through
zlib while keeping the same size cap enforced during
decompression. Plain SVG documents are also bounded by the
same 16 MiB limit.
Add a raster API regression that renders the existing
plain and compressed noto_handwriting SVG fixtures and
verifies identical output.
Testing:
- meson test -C build
Assisted-by: OpenAI Codex
Skip the SVG table accelerator and do not define the public
SVG color APIs when HB_NO_SVG is set. Guard internal
callers so SVG-table-dependent code compiles out cleanly,
and add HB_NO_SVG to the HB_TINY profile.
Tested: meson setup build-nosvg -Dc_args=-DHB_NO_SVG -Dcpp_args=-DHB_NO_SVG
Tested: meson compile -C build-nosvg hb-shape hb-info hb-vector main
Tested: meson compile -C build-nosvg (libharfbuzz/libharfbuzz-raster/libharfbuzz-vector linked; full tree stopped on unrelated missing chafa.h in util/hb-raster.cc)
Tested: nm -gU build-nosvg/src/libharfbuzz.0.dylib | grep -E "hb_ot_color_.*svg" (no matches)
Assisted-by: OpenAI Codex
Remove hb_raster_extents_from_glyph_extents and switch callers to the new transform-aware set_glyph_extents APIs on raster draw/paint. Also add test coverage for transformed glyph extents and update section symbol listings.
Renders glyph IDs 2-5 from fonts/adwaita.ttf at upem scale, writes
PGMs to /tmp/ for visual inspection, and asserts non-zero coverage.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix out-of-bounds pixel write in rasterize_tile: border tiles that
extend past the image edge were writing px-x_origin beyond the row
stride, wrapping into the start of the next row and overwriting
correctly-rasterized pixels with zero. Pass px1/py1 (exclusive
bounds) to rasterize_tile and clip the pixel loops accordingly.
Also: drop unused ex0 in pass 2 of tile assignment; move test-raster
from src/ to test/api/ and convert it to the GLib g_assert/hb_test_add
framework.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1. If smaller set has empty pages the subset checking logic was incorrectly incrementing the larger page index after skipping the empty smaller page index.
2. The logic for is_subset() on mixed inverted/not inverted sets was wrong.
- Make geometry types into templates taking float or double.
- Changes to paint() transform elimination.
- Add font->has_nonzero_coords and use it across.
- Extensions to avar processing for otherwise invalid mappings.
Faster. Note that this also means that if there is no clip-box,
we don't compute the bounds and emit an initial clip anymore.
That was totally unnecessary and against the COLRv1 rendering
algorithm.
This makes painting of COLRv1 fonts without clipboxes *much*
faster, as previously we were computing bounds using all subglyph
outlines. Not anymore.
Before:
BM_Font/paint_glyph/Nupuram-Color.colrv1.ttf/ot 1.78 ms
After:
BM_Font/paint_glyph/Nupuram-Color.colrv1.ttf/ot 0.155 ms
API change:
- hb_face_is_immutable() now takes `hb_face_t *` instead of previous
`const hb_face_t *`. This should not pose any problem for any
clients in our belief.