Commit Graph
20635 Commits
Author SHA1 Message Date
Behdad EsfahbodandClaude Opus 4.6 e8d2bddfab [gpu] Make GL deps optional; add them to Linux CI
The demo requires GLEW, GLFW3, and GL. Make these optional so the
library still builds on headless systems. The demo is skipped when
they're missing.

Install the GL packages in the Linux CI workflow so the demo
builds there.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 19:14:10 -06:00
Behdad EsfahbodandClaude Opus 4.6 65d357f808 [gpu] Rename hb_gpu_glyph_t to hb_gpu_draw_t
The object is a draw_funcs_t closure, same role as hb_raster_draw_t.
Rename for consistency with the other modules.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 19:09:40 -06:00
Behdad EsfahbodandClaude Opus 4.6 9732ad4bcf [gpu] Build hb-gpu binary in util/ instead of util/gpu/
Move the executable definition to util/meson.build so the binary
lands at util/hb-gpu, consistent with other utilities.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 18:50:41 -06:00
Behdad EsfahbodandClaude Opus 4.6 3ccec5b9ed [gpu] Fix double-free in hb_gpu_glyph_destroy
hb_object_destroy() already calls obj->~Type() for non-trivially-
destructible types, which runs hb_vector_t's destructor.  The
explicit curves.fini() was freeing the array a second time.

Also remove encode_buf reuse — allocate fresh each encode call
and let the blob own the buffer via its destroy callback.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 18:48:51 -06:00
Behdad EsfahbodandClaude Opus 4.6 294b625f7c [gpu] Wire up default font/text in demo
Fall back to an embedded font when no font file is given,
matching the glyphy-demo behaviour.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 18:32:21 -06:00
Behdad EsfahbodandClaude Opus 4.6 03c2688436 [gpu] Add GPU demo app in util/gpu
Port the glyphy-demo to use the hb-gpu API.  Builds as util/hb-gpu
and requires GLEW, GLFW3, and OpenGL 3.3.  Includes default text
and embedded font for quick testing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 18:30:13 -06:00
Behdad Esfahbod 93aab15340 [gpu] Add new hb-gpu module for GPU glyph encoding
Port the glyphy library into harfbuzz as a new hb-gpu module,
following the hb-raster / hb-vector library pattern.  The module
encodes glyph outlines into compact RGBA16I blobs for GPU rendering
using the Slug algorithm.

Fixes https://github.com/harfbuzz/harfbuzz/issues/5877
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 18:16:19 -06:00
Behdad EsfahbodandClaude Opus 4.6 e6d8ad97dc [vector] Use clear() instead of resize(0)/shrink(0) (#5876)
Also simplify clear() itself to just call shrink_vector(0) directly,
avoiding the resize() -> alloc() path which both fails in error state
and requires Type to be default-constructible.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 15:15:56 -06:00
Behdad Esfahbod 6e45962326 [raster] Guard direct SVG paint callbacks
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>
2026-03-26 14:41:14 -06:00
Behdad EsfahbodandClaude Opus 4.6 41de3c3272 [vector] Destruct items in clear() when vector is in error state
The previous fix (d134f888) zeroed `length` but skipped element
destructors. Call shrink_vector(0) instead, which properly destructs
items before clearing length.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 14:19:41 -06:00
Behdad Esfahbod 7433361337 [gpos] Guard cursive attachment reversal
Cursive attachment reversal clears the old child edge before
walking the existing chain and reinstalling reversed links.
If the chain distance does not stay in range for
attach_chain(), reinstalling the reversed edge can truncate
and leave a poisoned chain value.

Pass the buffer length into the reversal helper so it drops
out-of-bounds chains, and use a round-trip fit check before
storing the reversed distance. When the reversed distance does
not fit, leave the old edge detached instead of corrupting
the chain.

Testing: CCACHE_DISABLE=1 meson test -C build --print-errorlogs
Fixes https://issues.chromium.org/issues/496302307
Assisted-by: OpenAI Codex <codex@openai.com>
2026-03-26 14:14:57 -06:00
Behdad Esfahbod cbe62baf81 [raster] Increase max image buffer size
Somebody already hit it it seems.

Fixes https://github.com/harfbuzz/harfbuzz/issues/5874
2026-03-26 13:40:08 -06:00
Behdad Esfahbod 84d821ffac Remove two redundant conditionals
Fixes https://github.com/harfbuzz/harfbuzz/issues/5873
2026-03-25 11:59:58 -06:00
Behdad Esfahbod ef6a54cac3 [glyf] Reject simple glyphs with too few points
Reject simple glyf data that claims fewer points than contours.
Such data cannot describe a valid outline, so fail before
allocating and decoding contour points.

Testing: CCACHE_DISABLE=1 meson test -C b
Assisted-by: OpenAI Codex <codex@openai.com>
2026-03-24 14:26:42 -06:00
Behdad Esfahbod b268ba10ad [font] Fix typo in setting design coords (#5871)
Fixes https://github.com/harfbuzz/harfbuzz/security/advisories/GHSA-8p7p-f952-473p
2026-03-24 11:29:42 -06:00
Behdad Esfahbod e6a9f6e889 [font] Avoid div-by-zero in parent scale
Fixes https://github.com/harfbuzz/harfbuzz/security/advisories/GHSA-fw7p-wr9p-p9ww
2026-03-24 11:29:02 -06:00
Behdad Esfahbod 9b997ccc4e [font] Avoid creating a cycle in set_parent()
Fixes https://github.com/harfbuzz/harfbuzz/security/advisories/GHSA-6f7c-qw56-fvvr
2026-03-24 11:27:51 -06:00
Behdad Esfahbod ebda73ad65 [zlib] Remove unused macro 2026-03-24 11:26:16 -06:00
Behdad Esfahbod 30363077d2 Ignore -Warray-bounds
Fixes https://github.com/harfbuzz/harfbuzz/issues/5738
2026-03-24 11:25:59 -06:00
Behdad EsfahbodandClaude Opus 4.6 d134f88824 [vector] Fix clear() when vector is in error state
clear() called resize(0) which calls alloc(0), but alloc() bails
immediately when the vector is in error state, so length was never
zeroed. Under failing-malloc, a vector could enter error state from
a failed push, making all subsequent clear() calls silently fail,
leaving stale pointers.

This caused a heap-use-after-free in hb_raster_paint_destroy():
render() released surfaces to surface_cache then called
surface_stack.clear() which silently failed, so destroy() iterated
the stale surface_stack pointers and double-freed images already
in surface_cache.

Fixes https://oss-fuzz.com/testcase?key=5078588000108544

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-23 20:26:18 -06:00
Behdad Esfahbod 2cde8de822 [raster] Use png_jmpbuf in PNG error callback (#5868)
hb_raster_png_error() switched to png_longjmp() when raster PNG
error handling was hardened. That symbol is only available with
newer libpng headers, but HarfBuzz does not require a minimum
libpng version.

Follow cairo-png.c and jump through png_jmpbuf() instead. This
keeps the error path working with older libpng headers, including
macOS framework builds that pick up pre-1.5 libpng.

Testing:
meson test -C build

Fixes: https://github.com/harfbuzz/harfbuzz/issues/5867
Assisted-by: OpenAI Codex
2026-03-23 12:43:50 -06:00
dependabot[bot] 8dd76bb6b5 Bump hendrikmuhs/ccache-action from 1.2.20 to 1.2.21
Bumps [hendrikmuhs/ccache-action](https://github.com/hendrikmuhs/ccache-action) from 1.2.20 to 1.2.21.
- [Release notes](https://github.com/hendrikmuhs/ccache-action/releases)
- [Commits](https://github.com/hendrikmuhs/ccache-action/compare/5ebbd400eff9e74630f759d94ddd7b6c26299639...1bbbcda0748b3e340dee71a314fa68ffcbd6df79)

---
updated-dependencies:
- dependency-name: hendrikmuhs/ccache-action
  dependency-version: 1.2.21
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-23 13:58:14 +02:00
dependabot[bot] 9f3f9f16f1 Bump github/codeql-action from 4.33.0 to 4.34.1
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.33.0 to 4.34.1.
- [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/b1bff81932f5cdfc8695c7752dcee935dcd061c8...38697555549f1db7851b81482ff19f1fa5c4fedc)

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

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-23 13:57:54 +02:00
Behdad Esfahbod c34dd6e24b [buffer] Bounds-check in add_utf() (#5864)
Fixes https://github.com/harfbuzz/harfbuzz/security/advisories/GHSA-q4gc-p4hh-3765
2026-03-22 22:49:14 -06:00
DejanandDK 2763ae13d3 [ot-font] Skip adjusting offsets when all origin values are zero (#5863)
Co-authored-by: DK <dejan@Mac.ht.home>
2026-03-21 21:43:20 -06:00
DejanandDK 5b6645dabb Fix for issue #5847 (#5862)
Co-authored-by: DK <dejan@Mac.ht.home>
2026-03-20 23:33:00 -06:00
Behdad Esfahbod 074b6c826a Add a fuzzer test 2026-03-20 17:50:08 -06:00
Behdad Esfahbod 20fc6583b9 Revert "[rust] Use design coords if available, to set on the Rust side"
This reverts commit cb121fe0368d37ee599c8d4e168a5d139520cbcf.
2026-03-19 12:12:27 -06:00
Behdad Esfahbod 30f8744405 [rust] Use design coords if available, to set on the Rust side
Going to commit since not useful. Just wanted to record the code.
2026-03-19 12:12:27 -06:00
Behdad Esfahbod 90116a5297 Fuzzer fixes mar19 (#5861)
* [docs] Note failing-malloc in fuzzing guidance

Document that HarfBuzz fuzzers run with failing-malloc enabled so
out-of-memory handling remains part of the expected exercised
surface during fuzzing work.

Testing: not run (documentation-only change)

Assisted-by: OpenAI Codex

* Add a fuzzer font

* [vector] Fail closed on SVG paint body OOM

The SVG paint backend could keep going after failing-malloc
poisoned the root or nested group body buffers. In particular,
hb_vector_paint_ensure_initialized() only checked group_stack
itself, not the allocated root body, and some group and glyph
paths ignored push_or_fail() or append-induced vector error
state.

Treat an errored root body as initialization failure, reject
cached and non-cached glyph emission when defs, current body,
or captured scratch enter error state, and stop ignoring
nested group push failure.

Testing: CCACHE_DISABLE=1 meson test -C build-codex

Fixes: https://oss-fuzz.com/testcase-detail/4521131913838592
Assisted-by: OpenAI Codex

* [vector] Reject errored SVG paint bodies

Under failing-malloc, the SVG paint backend could leave the
root body or captured glyph body vector in an error state and
then keep appending to it. Group initialization only checked
group_stack itself, not the nested root body, and glyph
emission reported success even when defs, current body, or
captured scratch had entered vector error state.

Treat an errored root body as init failure, reject cached and
non-cached glyph emission once those vectors enter error, and
stop ignoring push_or_fail() in push_group().

Testing: CCACHE_DISABLE=1 meson test -C build-codex

Fixes: https://oss-fuzz.com/testcase-detail/4521131913838592
Assisted-by: OpenAI Codex
2026-03-19 10:20:22 -06:00
Behdad Esfahbod 488dfcf289 [vector] Reject errored SVG paint bodies
Under failing-malloc, the SVG paint backend could leave the
root body or captured glyph body vector in an error state and
then keep appending to it. Group initialization only checked
group_stack itself, not the nested root body, and glyph
emission reported success even when defs, current body, or
captured scratch had entered vector error state.

Treat an errored root body as init failure, reject cached and
non-cached glyph emission once those vectors enter error, and
stop ignoring push_or_fail() in push_group().

Testing: CCACHE_DISABLE=1 meson test -C build-codex

Fixes: https://oss-fuzz.com/testcase-detail/4521131913838592
Assisted-by: OpenAI Codex
2026-03-19 09:56:12 -06:00
Behdad Esfahbod be6fca21f5 [vector] Fail closed on SVG paint body OOM
The SVG paint backend could keep going after failing-malloc
poisoned the root or nested group body buffers. In particular,
hb_vector_paint_ensure_initialized() only checked group_stack
itself, not the allocated root body, and some group and glyph
paths ignored push_or_fail() or append-induced vector error
state.

Treat an errored root body as initialization failure, reject
cached and non-cached glyph emission when defs, current body,
or captured scratch enter error state, and stop ignoring
nested group push failure.

Testing: CCACHE_DISABLE=1 meson test -C build-codex

Fixes: https://oss-fuzz.com/testcase-detail/4521131913838592
Assisted-by: OpenAI Codex
2026-03-19 09:55:24 -06:00
Behdad Esfahbod 6af602fa64 Add a fuzzer font 2026-03-19 09:47:44 -06:00
Behdad Esfahbod 7e7a7085a8 [docs] Note failing-malloc in fuzzing guidance
Document that HarfBuzz fuzzers run with failing-malloc enabled so
out-of-memory handling remains part of the expected exercised
surface during fuzzing work.

Testing: not run (documentation-only change)

Assisted-by: OpenAI Codex
2026-03-19 09:41:46 -06:00
Khaled Hosny 6f4c5cec30 13.2.1 13.2.1 2026-03-19 16:09:56 +02:00
Khaled Hosny 09b79d14a0 [message] Fix start/end table GPOS message
Fix broken format from the previous change.
2026-03-19 16:07:30 +02:00
Khaled Hosny 5ad3909af4 13.2.0 13.2.0 2026-03-19 00:45:24 +02:00
Khaled Hosny 0ccf380469 [message] Improve start/end table GSUB/GPOS with HB_TAG_NONE
Use hb_tag_to_string() so we would get an empty string in this case
instead of calling HB_UNTAG() directly which would give us nul bytes
that would truncate the string.

Instead of:
trace: start table GSUB script tag '	buffer: [a=0]

We now get:
trace: start table GSUB script tag ''	buffer: [a=0]
2026-03-19 00:43:07 +02:00
Behdad Esfahbod c89f1c20b0 [raster] Harden color-stop fetches under failing malloc (#5858)
Malformed COLRv1 gradients can report a non-zero stop count and then
leave the effective stop array empty once allocations fail. The raster
path assumed the second fetch always produced at least one stop and
indexed stops[0], which let fuzzing hit a stack-buffer-underflow in
evaluate_color_line().

Reject empty effective stop lists after the second fetch, handle
zero-stop and one-stop evaluation defensively, and clamp non-finite
gradient parameters before lookup. Apply the same stop-fetch
hardening to the Cairo and vector paint helpers, including fixing
Cairos wrong NULL check after hb_malloc().

Testing: not run (per user request)

Fixes: https://oss-fuzz.com/testcase-detail/4635834988167168
Assisted-by: OpenAI Codex
2026-03-18 16:06:29 -06:00
Khaled Hosny 7191f88e56 Add start/end compose/decompose messages
Similar to start/end reorder messages. It does not give details on what
have been composed or decomposed as this seems to be tricky and one can
always deduce that from the changes to buffer contents.
2026-03-18 23:36:54 +02:00
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