Commit Graph
20650 Commits
Author SHA1 Message Date
Behdad EsfahbodandClaude Opus 4.6 df433afe6c [algs] Simplify hb_qsort: single template, inline all callers
Reduce to one templated hb_qsort, one templated qsort() on
hb_array_t/hb_vector_t, plus the no-arg qsort() that casts
Type::cmp to resolve ambiguity.

Convert all external call sites to lambdas so comparators
inline everywhere.  Remove the void*-arg overload and the
plain function-pointer overload.

225 tests pass, 0 failures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 12:50:30 -06:00
Behdad EsfahbodandClaude Opus 4.6 05762b2fac [algs] Template hb_qsort comparator for inlining
Make sort_r_simple and sort_r_cmpswap take the comparator as a
template parameter instead of a function pointer.  This allows
lambdas and functors to inline into the sort, avoiding the
indirect-call overhead.

The function-pointer overloads remain for backward compatibility
and for the __OPTIMIZE_SIZE__ / qsort_r paths.

17% speedup on GPU encode benchmark (NotoSansCJK).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 12:36:59 -06:00
Behdad EsfahbodandClaude Opus 4.6 583b13d95c [gpu] Fix stale parameter names in header; add section doc
Three declarations in hb-gpu.h still had *glyph instead of *draw.
Add SECTION doc block in new hb-gpu.cc for gtk-doc.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 22:33:29 -06:00
Behdad EsfahbodandClaude Opus 4.6 971e607319 [gpu] Add API test and google-benchmark encode benchmark
test-gpu: 7 subtests covering create/destroy, empty encode,
glyph encode, reset, draw funcs singleton, shader sources,
and recycle_blob.

benchmark-gpu: benchmarks draw, encode, and draw+encode
per-glyph across several fonts using google-benchmark.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 22:27:40 -06:00
Behdad EsfahbodandClaude Opus 4.6 33ad6419e3 [gpu] Remove std::sort; add qsort with context to hb_array_t
Add an hb_array_t::qsort overload that takes a comparator with a
void* context argument, forwarding to hb_qsort's existing qsort_r
support.  Use it in the GPU encoder to eliminate the last std::
usage from library code.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 19:48:10 -06:00
Behdad EsfahbodandClaude Opus 4.6 f5f6e90703 [gpu] Replace std:: with hb equivalents in encode
Use hb_min/hb_max instead of std::min/std::max, and
INT16_MIN/INT16_MAX instead of std::numeric_limits.
Only std::sort remains (needs lambda captures).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 19:43:45 -06:00
Behdad EsfahbodandClaude Opus 4.6 d9a81a9cc5 [gpu] Add hb-gpu to docs sections and docs index
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 19:40:13 -06:00
Behdad EsfahbodandClaude Opus 4.6 83fe2fa4fa [gpu] Fix doc comments: "GPU shape encoder", "GPU rasterization library"
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 19:37:52 -06:00
Behdad EsfahbodandClaude Opus 4.6 2e24eccfd3 [gpu] Use XSince: REPLACEME in doc comments
Per AGENTS.md, new API uses XSince not Since.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 19:34:51 -06:00
Behdad EsfahbodandClaude Opus 4.6 7828141773 [gpu] Use HUGE_VAL instead of INFINITY for double extents
INFINITY is float; assigning to double triggers -Wdouble-promotion.
HUGE_VAL is the double-precision infinity constant.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 19:32:48 -06:00
Behdad EsfahbodandClaude Opus 4.6 0c6ce48e8b [gpu] Rename encode local 'blob' to 'buf'
Avoid confusion with hb_blob_t variables.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 19:29:00 -06:00
Behdad EsfahbodandClaude Opus 4.6 cd6d6ce7bf [gpu] Fix -Wcast-align in encode buffer allocation
Allocate as hb_gpu_texel_t* directly instead of char* to avoid
an alignment-increasing cast.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 19:26:02 -06:00
Behdad EsfahbodandClaude Opus 4.6 69686b0768 [gpu] Use hb-gpu-demo name in help text and window title
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 19:23:17 -06:00
Behdad EsfahbodandClaude Opus 4.6 4c78e3bf67 [gpu] Rename demo binary to hb-gpu-demo
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 19:21:12 -06:00
Behdad EsfahbodandClaude Opus 4.6 39811d2933 [gpu] Rename parameter 'glyph' to 'draw'; inline encode_impl
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 19:20:10 -06:00
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