Commit Graph
20595 Commits
Author SHA1 Message Date
Khaled Hosny 257769a9d2 [ot-shape] Add hb_ot_shape_get_buffer_format_serial() (#5857) 2026-03-18 10:24:52 -06:00
Behdad Esfahbod 5fc1d612f9 Merge pull request #5854 from harfbuzz/more-fuzzer-fixes
More fuzzer fixes
2026-03-17 09:54:44 -06:00
Behdad Esfahbod 4462e9862d [vector][colr] Guard color_glyph reentry in SVG paint backend
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
2026-03-17 09:39:46 -06:00
Behdad Esfahbod df9b6ff641 [vector][colr] Sanitize ColorLine extend values
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
2026-03-17 09:33:31 -06:00
Behdad Esfahbod acc0a54ddc [raster] Remove remaining signed-shift UB in edge stepping
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
2026-03-17 09:27:48 -06:00
Behdad Esfahbod bdbf83e26d [raster] Avoid signed-shift UB in scanline y conversion
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
2026-03-17 09:19:07 -06:00
Behdad Esfahbod b4115f23ee [subset] Harden renormalizeValue for malformed avar triples
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
2026-03-17 09:12:35 -06:00
Behdad Esfahbod ba53130d2c [vector][svg] Harden subset spans under failing-malloc
Validate cached SVG spans before use and make cache parsing
allocation-failure safe.

Fixes: https://oss-fuzz.com/testcase-detail/5448347908636672
Assisted-by: OpenAI Codex
2026-03-17 09:12:35 -06:00
dependabot[bot] 53cd1e5b08 Bump setuptools from 82.0.0 to 82.0.1 in /.ci
Bumps [setuptools](https://github.com/pypa/setuptools) from 82.0.0 to 82.0.1.
- [Release notes](https://github.com/pypa/setuptools/releases)
- [Changelog](https://github.com/pypa/setuptools/blob/main/NEWS.rst)
- [Commits](https://github.com/pypa/setuptools/compare/v82.0.0...v82.0.1)

---
updated-dependencies:
- dependency-name: setuptools
  dependency-version: 82.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-16 15:46:14 +02:00
dependabot[bot] e473039414 Bump fonttools from 4.61.1 to 4.62.1 in /.ci
Bumps [fonttools](https://github.com/fonttools/fonttools) from 4.61.1 to 4.62.1.
- [Release notes](https://github.com/fonttools/fonttools/releases)
- [Changelog](https://github.com/fonttools/fonttools/blob/main/NEWS.rst)
- [Commits](https://github.com/fonttools/fonttools/compare/4.61.1...4.62.1)

---
updated-dependencies:
- dependency-name: fonttools
  dependency-version: 4.62.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-16 15:45:54 +02:00
dependabot[bot] d742a74883 Bump meson from 1.10.1 to 1.10.2 in /.ci
Bumps [meson](https://github.com/mesonbuild/meson) from 1.10.1 to 1.10.2.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/1.10.1...1.10.2)

---
updated-dependencies:
- dependency-name: meson
  dependency-version: 1.10.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-16 15:45:32 +02:00
dependabot[bot] 0545567fe6 Bump actions/download-artifact from 8.0.0 to 8.0.1
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 8.0.0 to 8.0.1.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3...3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: 8.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-16 15:45:01 +02:00
dependabot[bot] f0aba51eec Bump github/codeql-action from 4.32.6 to 4.33.0
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.32.6 to 4.33.0.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/0d579ffd059c29b07949a3cce3983f0780820c98...b1bff81932f5cdfc8695c7752dcee935dcd061c8)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: 4.33.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-16 15:44:37 +02:00
Behdad Esfahbod 73a3393915 Merge pull request #5844 from harfbuzz/fuzzer-fixes
Fuzzer fixes
2026-03-14 14:08:18 -06:00
Behdad Esfahbod 6815666a74 [raster] Preserve base transform on failed pushes
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
2026-03-14 13:29:51 -03:00
Behdad Esfahbod 2b93ac44e1 [raster] Fast-path axis-aligned clip rectangles on masks
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
2026-03-14 13:25:34 -03:00
Behdad Esfahbod 03006b06ba [raster] Avoid signed-shift UB in edge slope setup
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
2026-03-14 13:22:56 -03:00
Behdad Esfahbod cb0757aad9 [raster] Reject empty gradient stop lists
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
2026-03-14 13:19:29 -03:00
Behdad Esfahbod ef191e9b2c [raster] Guard SVG stack pops on allocation failure
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
2026-03-14 13:17:05 -03:00
Khaled Hosny 8168bf5fe0 [docs] Remove note about old HarfBuzz
Old HarfBuzz is long long dead that this note is likely to just confuse
people now.
2026-03-14 10:51:47 +02:00
Behdad Esfahbod c197509b4b [vector] Avoid stale SVG paint body references (#5843)
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
2026-03-13 14:32:22 -06:00
Khaled Hosny 8fbf89c638 [docs] Re-order API sections a bit
Keep libharfbuzz APIs together, except for the integration APIs which
now comes last.
2026-03-13 15:28:29 +02:00
Behdad Esfahbod 870ba327f7 [util] Preserve --ned positioning in --glyphs input
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
2026-03-13 14:39:42 +02:00
Khaled Hosny 70b812d8d2 13.1.1 13.1.1 2026-03-13 03:08:03 +02:00
Behdad Esfahbod 70de901d39 [cmake] Add raster and vector libraries
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
2026-03-13 01:21:13 +02:00
Behdad Esfahbod 01f1125c8c [varStore] Handle >65535 items per encoding (#5840)
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
2026-03-12 10:29:21 -06:00
Khaled Hosny 9cb1fee510 [meson] Update wraps 2026-03-12 17:36:39 +02:00
Khaled Hosny 6e267000a1 [meson] Add libpng and zlib wraps 2026-03-12 17:36:39 +02:00
Khaled Hosny b327f0c672 [tests] Fix warning when building without zlib
../test/api/test-raster.cc:67:1: warning: unused function 'render_svg_glyph' [-Wunused-function]
   67 | render_svg_glyph (hb_face_t      *face,
      | ^~~~~~~~~~~~~~~~
1 warning generated.
2026-03-12 17:36:39 +02:00
Khaled Hosny 3e2897e631 [hb-raster] Fix building with PNG disabled
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.
2026-03-12 17:36:39 +02:00
Khaled Hosny a79a8257bb [meson] Add options for libpng and zlib 2026-03-12 17:36:39 +02:00
Behdad Esfahbod 6ad6a2fe82 [COLR] Propagate clip extents failures
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
2026-03-12 17:19:14 +02:00
Behdad EsfahbodandQuang Luong 91085cd990 Guard VarData itemCount overflow (#5836)
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>
2026-03-12 08:57:35 -06:00
Khaled Hosny 283b568114 [ci] Enable chafa on macOS builds 2026-03-12 16:39:24 +02:00
Khaled Hosny 63f094711b [ci] Enable chafa on Linux builds 2026-03-12 16:39:24 +02:00
Behdad Esfahbod 3786b83fa6 [amalgamation] Add HB_HAS_SUBSET and share SVG helpers (#5835)
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
2026-03-12 08:32:37 -06:00
Behdad Esfahbod 5d4e96ad8d Merge pull request #5824 from harfbuzz/svgz
[raster] Support gzip-compressed SVG documents
2026-03-11 23:55:52 -06:00
Behdad Esfahbod a7a077d95c Merge branch 'main' into svgz 2026-03-11 23:55:41 -06:00
Behdad Esfahbod 4da15dadff [meson] Add raster/vector feature macros
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
2026-03-12 02:53:11 -03:00
Behdad EsfahbodandClaude Opus 4.6 27f02bd093 [docs] Add Assisted-by trailer guidance to AI conduct policy
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>
2026-03-12 02:48:26 -03:00
Behdad Esfahbod fca580e928 [docs] Clarify commit message formatting
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
2026-03-12 02:48:26 -03:00
Behdad Esfahbod d433fc3593 [docs] Add AI contribution policy
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
2026-03-12 02:48:26 -03:00
Behdad Esfahbod 1607db6970 [svg] Keep zlib private to raster and vector SVG decoding
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
2026-03-12 02:41:44 -03:00
Behdad Esfahbod 8e6b9ecf4e [test] Add vector coverage for handwriting color fonts
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
2026-03-12 01:49:07 -03:00
Behdad Esfahbod 8fc1d1bfd1 [vector] Allow duplicate SVG refs during subsetting
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
2026-03-12 01:46:46 -03:00
Garret Rieger 07a9ad2ed1 For the CFF overflow fix use remaining instead of total bytes to avoid any possible overflow in the total bytes count. (#5826) 2026-03-11 19:15:21 -06:00
Behdad Esfahbod 2ea0e18a43 [util] Move shared ANSI image helpers out of Cairo wrapper
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
2026-03-11 22:12:40 -03:00
Behdad Esfahbod fd8535af45 [vector] Keep extracted root SVG overflow visible
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
2026-03-11 21:03:31 -03:00
Behdad Esfahbod d9116dda9c [svg] Use em-square root viewport fallback
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
2026-03-11 20:51:41 -03:00
Behdad Esfahbod 00da68ef5c [svg] Share svgz normalization across raster and vector
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
2026-03-11 20:23:51 -03:00