The vector color_glyph callback can re-enter painting through
PaintColrGlyph, creating an unbounded callback recursion path that does
not consume COLR paint-context depth counters.
Track active color glyphs to reject immediate/indirect cycles and add a
hard nested callback depth cap based on HB_MAX_NESTING_LEVEL.
Tested:
- CCACHE_DISABLE=1 ninja -C /home/behdad/harfbuzz/build-codex test/fuzzing/hb-vector-fuzzer
- for f in test/fuzzing/fonts/crash-* test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-vector-fuzzer-*; do ./build-codex/test/fuzzing/hb-vector-fuzzer "$f"; done
Fixes: https://oss-fuzz.com/testcase-detail/5985308075425792
Assisted-by: OpenAI Codex
COLR ColorLine::get_extend() cast the raw Extend byte directly to
hb_paint_extend_t. Malformed tables can carry out-of-range values,
which then trip UBSan enum checks in vector paint paths.
Map raw extend values explicitly and fall back to PAD for unknown
values.
Tested:
- CCACHE_DISABLE=1 ninja -C /home/behdad/harfbuzz/build-codex test/fuzzing/hb-vector-fuzzer test/fuzzing/hb-raster-fuzzer
- ./build-codex/test/fuzzing/hb-vector-fuzzer test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-vector-fuzzer-5448347908636672
- ./build-codex/test/fuzzing/hb-vector-fuzzer test/fuzzing/fonts/NotoColorEmoji.subset.ttf
Fixes: https://oss-fuzz.com/testcase-detail/6120408016551936
Assisted-by: OpenAI Codex
Raster edge setup still had signed-shift UB in two places:
- slope scaling in emit_segment() when dx is negative
- x-boundary stepping in edge_sweep_row() when cx0 is negative
Compute slope with widened subtraction and multiplication, and compute
x_b using widened multiply plus clamp.
Tested:
- ./build-codex/test/fuzzing/hb-raster-fuzzer test/fuzzing/fonts/crash-d223bc42a8226c4d655c417d63d9a76760d05985
- ./build-codex/test/fuzzing/hb-raster-fuzzer test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-raster-fuzzer-6454028543524864
Assisted-by: OpenAI Codex
hb_raster_draw_render() computed y_top by left-shifting a signed value
that can be negative when extents have a negative y origin.
Switch to 64-bit multiplication by HB_RASTER_ONE_PIXEL and clamp to
int32_t range before use, preserving behavior without signed-shift UB.
Tested:
- CCACHE_DISABLE=1 ninja -C /home/behdad/harfbuzz/build-codex test/fuzzing/hb-raster-fuzzer
- ./build-codex/test/fuzzing/hb-raster-fuzzer test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-raster-fuzzer-6454028543524864
Fixes: https://oss-fuzz.com/testcase-detail/6454028543524864
Assisted-by: OpenAI Codex
Avoid abort/assert in renormalizeValue when avar triples are malformed
and guard zero-distance divisions.
Add a regression case in test-subset-instancer-solver and include the
OSS-Fuzz reproducer file.
Fixes: https://oss-fuzz.com/testcase-detail/6461128124465152
Assisted-by: OpenAI Codex
The raster backend lets push_transform() fail under the fuzzing failing-
allocator path, but pop_transform() always removed the current stack
entry. That can discard the base transform when a nested push did not
actually land, corrupting subsequent raster operations.
Guard pop_transform() so it only removes nested transforms and preserves
the base transform frame.
Tested:
- meson compile -C build hb-raster-fuzzer
Speculative fix for: https://oss-fuzz.com/testcase-detail/4743569679384576
Assisted-by: OpenAI Codex
hb_raster_paint_push_clip_rectangle() already has an O(1) fast path for
axis-aligned rectangle clips when the existing clip is also a rectangle.
If the existing clip is an alpha mask, the code fell back to the generic
quad rasterization loop even though the new clip was still axis-aligned.
That makes malformed COLR inputs spend large amounts of time in the per-
pixel inside-quad test. Intersect axis-aligned rectangle clips with an
existing alpha mask by copying only the intersecting row spans.
Tested:
- meson compile -C build hb-raster-fuzzer
Assisted-by: OpenAI Codex
emit_segment() formed its 16.16 fixed-point slope by left-shifting a
signed delta-x value. Negative dx values make that shift undefined, and
UBSan reports it on malformed glyph outlines.
Use 64-bit multiplication by 1<<16 instead, preserving the same fixed-
point result without relying on signed-shift behavior.
Tested:
- meson compile -C build hb-raster-fuzzer
Fixes: https://oss-fuzz.com/testcase-detail/4797078076456960
Assisted-by: OpenAI Codex
The raster gradient code assumed every color line had at least one stop.
Malformed COLR data can report an empty stop list, which then reaches
normalize_color_line() and evaluate_color_line() and reads stops[0].
Treat empty color lines as a failed gradient fetch so malformed inputs
render nothing instead of dereferencing past the stop array.
Tested:
- meson compile -C build hb-raster-fuzzer
Fixes: https://oss-fuzz.com/testcase-detail/5216672087867392
Assisted-by: OpenAI Codex
The raster SVG renderer assumed push_group() and push_transform()
always succeeded. Under the fuzzing failing-allocator path those pushes
can fail, but the matching pops still ran unconditionally.
When SVG rendering is nested inside an existing paint operation, an
unmatched pop can remove the caller's transform or group and later trip
the stack-balance assertions.
Track whether each raster SVG push actually grew the corresponding stack
and only pop in that case.
Tested:
- meson compile -C build hb-raster-fuzzer
- build/test/fuzzing/hb-raster-fuzzer test/fuzzing/fonts/NotoColorEmoji.subset.ttf
Fixes: https://oss-fuzz.com/testcase-detail/5627961964560384
Assisted-by: OpenAI Codex
The non-cached SVG paint path kept a reference to the current group
body across hb_font_paint_glyph_or_fail(). Nested paint groups can
grow group_stack and move its storage, leaving that reference dangling.
Append to current_body() directly before and after the recursive
paint call so the code never reuses a body reference after the stack
may have reallocated.
Fixes: https://oss-fuzz.com/testcase-detail/5622008821121024
Testing: meson test -C build
Assisted-by: OpenAI Codex
When `--glyphs` input omitted advances but still carried `@`
positions, the util-side parser synthesized default advances from the
font. That changed the logical width of `hb-shape --ned` output and
broke same-size round-trips through `hb-view --glyphs`.
Only synthesize advances when the glyph string has neither explicit
advances nor explicit positions.
Tested:
- meson test -C build
Fixes: https://github.com/harfbuzz/harfbuzz/issues/5377
Assisted-by: OpenAI Codex
Wire harfbuzz-raster and harfbuzz-vector into the
community-maintained CMake build so they are built,
installed, and exported like the existing optional
libraries.
Also install their public headers, generate pkg-config
files for them, and expose HB_HAS_SUBSET/HB_HAS_RASTER/
HB_HAS_VECTOR in hb-features.h.
Testing:
meson test -C build
Assisted-by: OpenAI Codex
Split optimized encodings into multiple VarData subtables before
rebuilding VariationIndex mappings. This keeps itemCount within the
16-bit limit when the optimizer produces more than 65535 rows for a
single encoding.
Add a regression test that mirrors the FontTools overflow case and
checks the split boundaries in the remapped VarIdx output.
Testing: meson compile -C build test-item-varstore
Testing: ./build/src/test-item-varstore
Fixes: #5839
Assisted-by: OpenAI Codex
In file included from ../util/hb-raster.cc:30:
../util/raster-output.hh:828:16: error: a type specifier is required for all declarations
828 | HB_UNUSED (img);
| ^
../util/raster-output.hh:829:16: error: a type specifier is required for all declarations
829 | HB_UNUSED (protocol);
| ^
2 errors generated.
ClipList::get_extents() returned true for any matching clip record,
even when the underlying ClipBox rejected the request.
That left the output extents uninitialized and the paint path could
pass them to scale_glyph_extents(), which shows up under
MemorySanitizer in clipped COLRv1 raster painting.
Return the ClipRecord result directly so invalid clip boxes fail
cleanly instead of exposing uninitialized extents.
Fixes: https://oss-fuzz.com/testcase-detail/4659742604853248
Assisted-by: OpenAI Codex
Reject oversized merged VarData row sets before assigning them to the
16-bit itemCount field. This avoids truncating the serialized allocation
size and prevents the subsequent row write loop from running out of
bounds.
src/hb-ot-layout-common.hh | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Co-authored-by: Quang Luong <oss@engineer.ink>
Add HB_HAS_SUBSET to hb-features.h and wire it through the same
HAVE_* feature plumbing used by the other HB_HAS_* macros.
Refactor the raster/vector SVG helper code so the duplicated
private helpers live in shared internal headers, avoiding
duplicate definitions when sources are combined in a single
translation unit.
Testing: meson compile -C build
Assisted-by: OpenAI Codex
Raster and vector libraries were configurable, but hb-features.h.in
did not expose matching HB_HAS_* macros.
Set HAVE_RASTER and HAVE_VECTOR during configuration, include both
features in the generated hb-features.h list, and add them to the
gtk-doc section index.
Testing: meson test -C build
Assisted-by: OpenAI Codex
Replace the vague "disclose significant AI assistance in the PR
description" with a concrete Assisted-by: trailer recommendation,
consistent with what AGENTS.md already requires for agent commits.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add a note to AGENTS.md to avoid passing literal \n sequences
in commit bodies when using shell commands.
Testing: not run (documentation-only change)
Assisted-by: OpenAI Codex
Document expectations for AI-assisted contributions in a dedicated
policy file. The guidance keeps contributors accountable for
verification, narrow diffs, confidentiality, and licensing.
Testing: not run (documentation-only change)
Fixes: #5790
Assisted-by: OpenAI Codex
The core libharfbuzz SVG table code should not include zlib headers or
link against zlib. Only the raster and vector libraries need to
normalize svgz documents before parsing them.
Move the gzip decoder into a private hb-zlib translation unit that is
built only by harfbuzz-raster and harfbuzz-vector, and move SVG blob
normalization into a private helper header used only there. Keep the
shared SVG table and cache logic in libharfbuzz free of zlib includes.
Assisted-by: OpenAI Codex
Extend the vector regression tests to cover the remaining handwriting
fuzzing fonts: sbix, glyf COLRv1, and CFF/CFF2 COLRv1.
Reuse the expected output where the CFF and CFF2 variants serialize
identically.
Assisted-by: OpenAI Codex
Some SVG glyph documents reuse the same referenced element multiple
times. The vector subsetter treated a duplicate ref as a hard failure,
which made hb-vector drop glyphs like U+270D from the handwriting
picosvg test fonts entirely.
Treat duplicate and empty refs as non-fatal while still uniquing the
collected ids. Add regressions for the handwriting picosvg and picosvgz
fonts, reusing a shared expected output for the pair.
Fixes: https://github.com/harfbuzz/harfbuzz/issues/5829
Assisted-by: OpenAI Codex
The RGB24-to-ANSI output path was implemented in helper-cairo-ansi.hh,
so hb-raster picked up a Cairo header dependency even though it only
needed the shared image-output code. That broke builds configured with
-Dcairo=disabled.
Move the shared callback, Chafa, and RGB24-to-ANSI helpers into
helper-image-output.hh, keep helper-cairo-ansi.hh focused on adapting
Cairo surfaces, and switch raster-output.hh to include only the shared
image helper.
Testing:
meson test -C build
Assisted-by: OpenAI Codex
When hb-vector emits a root SVG glyph document as a nested <svg>, browser
SVG renderers clip it to that nested viewport. OpenType SVG root documents
are not meant to be clipped that way.
Set overflow="visible" on extracted root SVG glyphs so browser rendering
matches the intended OpenType SVG behavior.
Tested:
- meson test -C build
Assisted-by: OpenAI Codex
Root SVG documents in OpenType SVG glyph data can omit width and height
while still defining a viewBox. HarfBuzz was falling back to the viewBox
size in that case, which made fonts like emojione-svg.otf render with the
wrong placement and scale.
Use the font upem as the fallback viewport size for the root SVG document.
Raster now applies that when mapping the root viewBox, and vector injects
matching width/height on extracted root SVG glyph documents.
Tested:
- meson test -C build
Assisted-by: OpenAI Codex
Vector SVG extraction still treated SVG table documents as plain text,
so svgz payloads worked in raster but failed in hb-vector.
Move the gzip helpers into a new internal hb-zlib.hh header and add a
shared SVG blob normalization helper in svg.hh. Raster and vector now
both normalize SVG documents before doc-cache or rendering/subsetting
logic sees them, with the same 16 MiB uncompressed size limit.
Also link zlib into harfbuzz-vector when available and add a vector
regression that checks matching output for the existing plain and
compressed handwriting SVG fonts.
Tested:
- meson test -C build
Assisted-by: OpenAI Codex