Commit Graph
2977 Commits
Author SHA1 Message Date
Behdad Esfahbod bd35da613d [test] Remove disabled advance checks from the obsolete proposal
Delete the remaining dead assertions for the old beyond-64K hmtx
extension, along with their stale adaptation comment. The current
specification uses separate capital-letter tables.

Leave the active legacy-table assertions and fixture unchanged.

Testing: full Meson suite: 281 passed, one skipped.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-02 11:22:24 -06:00
Behdad Esfahbod c034548995 [subset] Preserve the unrounded sign of constant layout conditions
Partial instancing used the rounded positioning delta to fold format-2
conditions. A positive fraction could round to zero and lose a lookup.
Evaluate the original GDEF store at the pinned/default coordinates when
the projected variation index becomes NO_VARIATION_INDEX instead.

Keep integer rounding for conditions with remaining variation and for
ordinary positioning values. The new helper is internal-only.

Extend the legacy condition grid and add an additive lookup regression
using existing fonts. The full Meson suite passes (281 tests, one skip),
including shape and subset suites. All 32 cross-library full/partial
GSUB/GPOS instancing diagnostics preserve the original shaping.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-02 11:09:38 -06:00
Behdad Esfahbod e5ce527941 [cff2] Support VARC glyphs beyond the CharStrings INDEX
OFF permits CFF2 CharStrings to omit a tail of glyphs provided by
VARC. Accept this count mismatch only when VARC is present, and
validate FDSelect against both the CharStrings and font glyph counts.
Reject malformed explicit FDSelect tables instead of using FD zero.

Add draw and count-mismatch regressions, plus FDSelect format 3 and 4
sentinel checks. The full Meson suite passes: 281 passed, 1 skipped.
C++11 syntax checks pass with extended and reduced features.

Assisted-by: OpenAI Codex <noreply@openai.com>
2026-10-02 06:43:14 -06:00
Behdad Esfahbod 955770eaa8 [subset] Preserve universal first-match records after axis pinning
A satisfied condition set becomes universal when all its conditions are
dropped, even if no remaining condition requested retention. Mark that
record universal and retain it while other axes remain, preventing
later records and an obsolete default catch-all from changing behavior.

Serialize reduced unconditional records with a null ConditionSet.
Regress GSUB and GPOS together, with an earlier conditional record and
LookupVariationRecord ADD_DEFAULT_LOOKUPS interaction. Regenerate the
existing instance goldens for the unconditional-record representation.

Testing: full Meson suite, 281 passed and one expected skip.

Assisted-by: OpenAI Codex <noreply@openai.com>
2026-10-02 06:20:51 -06:00
Behdad Esfahbod 81b68595b1 [subset] Instance FeatureVariationRecord condition formats 2-5
Legacy FeatureVariationRecords forced non-axis conditions to false when
choosing the new default features. Their empty range maps also compared
equal, discarding distinct conditional records during partial instancing.

Evaluate value and boolean conditions against the original GDEF store
at the new default, classify their surviving ranges conservatively, and
avoid range-only deduplication for complex conditions. Reuse the lookup
condition serializer to fold pinned axes and remap variation indices.
Materialize a false condition rather than emitting a null (true) offset.
Remove the unused condition-subset TODO stubs.

Add GSUB/GPOS coverage with 75 full/partial-instancing comparisons of
glyph selection and advances, covering formats 2-5 and null children.

Testing: meson test -C build (281 passed, 1 skipped); C++11 reduced-
feature syntax checks with HB_NO_VAR, HB_NO_BEYOND_64K, HB_NO_CUBIC_GLYF.

Assisted-by: OpenAI Codex <noreply@openai.com>
2026-10-02 04:49:46 -06:00
Behdad Esfahbod 02c6a9f935 [glyf] Preserve cubic control pairing across contours
Starting every contour at its last point rotates all-off-curve cubic
controls by one point, changing the implied curves. Preserve their
original order instead. Reset the second leading control between
contours, and draw a two-control contour as a cubic, not a point.

Add regressions using current MAXP, GLYF, LOCA, HHEA, and HMTX tables
for all-off-curve contours, consecutive contours, and two controls.

Testing: meson test -C build (281 passed, 1 skipped).

Assisted-by: OpenAI Codex <noreply@openai.com>
2026-10-02 04:31:02 -06:00
Behdad Esfahbod 95f11782f1 [test] Remove obsolete loca glyph-count checks
The disabled checks reflect an abandoned beyond-64k proposal that
derived the glyph count from loca. Remove them while retaining the
active maxp compatibility and fallback tests.

Testing: meson test -C build (281 passed, 1 skipped).

Assisted-by: OpenAI Codex <noreply@openai.com>
2026-10-02 04:27:54 -06:00
Behdad Esfahbod f072bff4b0 [ot] Exercise GPOS lookup variations
Extend the lookup-variation fixture with a GDEF ItemVariationStore-backed
ConditionValue and a GPOS conditional positioning lookup. This covers
variation-index evaluation, GPOS shaping, and lookup collection while
reusing the existing partial-instancing checks.

Tested with the full Meson suite and OTS validation of the fixture.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-01 20:40:06 -06:00
Behdad Esfahbod 3f39e24e75 [subset] Partially instantiate lookup conditions
Reduce LookupVariationRecord conditions to false, true, or a residual
condition when axes are pinned or restricted.  Fold compound AND, OR,
and NOT conditions, remap value-condition variation indices, and emit a
constant condition when a surviving lookup becomes unconditional.

Extend the test font with a second axis and all condition formats so the
subset tests cover structural, full, and partial instancing behavior.

Tested with the full Meson test suite, targeted Clang HB_NO_VAR and GCC
builds, and OTS validation of the fixture.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-01 19:43:47 -06:00
Behdad Esfahbod c8d6c273fb [subset] Instantiate LookupVariationRecord lookups
Resolve lookup variations at the pinned coordinates and store their final
lookup sets in the subset plan.  Use those sets when serializing the main
Feature tables before dropping FeatureVariations from a full instance.

This reuses the shaping resolver so version 1.0 feature substitutions,
ADD_DEFAULT_LOOKUPS, compound conditions, and GDEF variation data are
evaluated consistently.

Tested with the full Meson test suite and a targeted HB_NO_VAR build.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-01 19:31:11 -06:00
Behdad Esfahbod 3d6677f05c [subset] Preserve LookupVariationRecord tables
Subset FeatureVariations 1.1 lookup records while remapping feature and
lookup indices.  Preserve all condition formats and remap variation
indices used by value conditions.

Keep features with lookup variations distinct during feature
deduplication, since equal default lookup lists do not imply equal
variable behavior.

Tested with the full Meson test suite and a targeted HB_NO_VAR build.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-01 19:25:17 -06:00
Behdad Esfahbod 48d97c4ad1 [ot] Collect LookupVariationRecord dependencies
Include conditionally referenced lookups in layout collection, feature
closure, and GSUB dependency data.  Also retain variation indices used
by FeatureVariations conditions in GSUB and GPOS when remapping the
GDEF variation store.

Tested with the full Meson test suite and targeted HB_NO_VAR builds of
the touched runtime translation units.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-01 19:14:01 -06:00
Behdad Esfahbod 2c05df744c [ot] Support LookupVariationRecord shaping
Parse and sanitize the FeatureVariations 1.1 lookup-oriented records.
Resolve their effective lookup sets while constructing the shape-plan
key so cache entries remain exact without retaining raw coordinates.

Handle ADD_DEFAULT_LOOKUPS, multiple matching conditions, and the
interaction with version 1.0 feature substitutions.  Keep the existing
public FeatureVariations query API behavior unchanged.

Tested with the full Meson test suite.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-01 19:08:11 -06:00
Behdad Esfahbod c27beebf87 [VORG] Use published versions in tests
Encode versions 1.0 and 2.0 in the VORG fixtures instead of the undefined
minor version 1. The test behavior is unchanged, but the input now conforms
to the final Open Font Format definition.

Tested with test-be-subset-tables and the full Meson suite.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-01 16:51:20 -06:00
Behdad Esfahbod 58a90bf833 [cmap] Support DMAP
Consult DMAP before cmap for nominal and variation mappings, and combine
their character coverage while retaining DMAP precedence. Reuse the cmap
parser and serializer for DMAP, including effective subsetting closure.

Keep DMAP available independently of beyond-64K support; only cmap format
15 remains conditional.

Tested with the full Meson suite and with an HB_NO_BEYOND_64K build.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-01 16:27:20 -06:00
Behdad Esfahbod e109b81788 [GVAR] Correct extended header size
Account for the uint24 glyphCount field when reserving the uppercase
GVAR header. The fixed 20-byte size caused the final byte of the
glyphVariationDataArrayOffset to overlap the first array offset.

Add an exact binary subsetting regression for the 21-byte header.

Testing: meson test -C build --print-errorlogs

Assisted-by: OpenAI Codex
2026-10-01 14:47:15 -06:00
Behdad Esfahbod 3d5736e8ab [GDEF] Restore version 1.4 header layout
Use the final version 1.4 header with five appended Offset32 fields
instead of the obsolete major-version-2 layout.  Honor each nonzero
Offset2 field in preference to its legacy counterpart when reading and
subsetting the table.

Add a binary regression test that gives the legacy and extended glyph
class definitions different values, ensuring the extended field wins.

Testing: meson test -C build

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-01 13:21:30 -06:00
Behdad Esfahbod 17af97aae4 Merge remote-tracking branch 'origin/main' into beyond-64k
Reconcile the beyond-64K table type changes with the dependency API,
graph result handling, and variation-budget updates from main. Preserve
the branch's wider table variants while adopting the new behavior.

Build and test with Meson (281 passed, 1 skipped).

Assisted-by: OpenAI Codex <noreply@openai.com>
2026-10-01 12:59:54 -06:00
Behdad EsfahbodandClaude Sonnet 5.5 e6d5454350 [paint] Clamp hb_color_lerp() channels to [0,255] (#6305)
Sweep-gradient color-stop angles come from the font, so the
interpolation fraction t can fall outside [0,1] (or be NaN).  The
interpolated channel was then cast float -> unsigned directly; a
negative value (e.g. -387.671) is UB (UBSan float-cast-overflow) and
yields meaningless colors on release builds.

Clamp the interpolated channel to [0,255], mapping NaN to 0, before
the cast.  In-range behavior is unchanged.  Add the reported fuzzer
input as a seed.

Reported by iceray-Li.

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-09-30 18:22:41 -06:00
Behdad EsfahbodandClaude Sonnet 5.5 b7fca823a0 [avar] Clamp instantiated axis-value maps to F2DOT14 range (#6303)
AxisValueMap::instantiate() renormalizes the from/to coordinates and
stores them with set_float() without clamping.  With malformed input
the result can fall outside [-1,1] (e.g. 2.192 -> 35923), overflowing
the int16 F2DOT14 storage: UB under UBSan's float-cast-overflow, and a
silently truncated avar table otherwise.

Clamp both coordinates to [-1,1] before storing.  Add the reported
fuzzer input as a seed.

Reported by iceray-Li.

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-09-30 18:03:28 -06:00
Behdad EsfahbodandClaude Sonnet 5 cb995b5754 [ft] Fix self-deadlock in hb_font_destroy() after hb_ft_font_set_funcs() (#6300)
on a stream-backed FT_Face

hb_ft_font_set_funcs() creates its own internal FT_Face from the
font's face blob, and hooks that blob to the FT_Face's generic
finalizer (_release_blob), with the shared static FT_Library hooked
to the blob's user-data destructor (destroy_ft_library).

On hb_font_destroy(), _hb_ft_face_destroy_static() locks
static_ft_library_mutex and calls FT_Done_Face(), which synchronously
runs the finalizer chain: _release_blob() -> hb_blob_destroy(). For a
face created from a custom FreeType stream (FT_OPEN_STREAM), each
hb_face_reference_blob() call synthesizes a brand-new, unshared blob
(via _hb_ft_reference_table()), so this hb_blob_destroy() call drops
it straight to zero, which triggers destroy_ft_library(), which tries
to lock the same non-recursive static_ft_library_mutex again on the
same thread. Self-deadlock.

This didn't reproduce for a file-path or memory-blob face, because
there the blob handed to the internal FT_Face is the same blob shared
by the outer hb_face_t, so the drop inside the lock only decrements
its refcount without reaching zero; the final unref (and
destroy_ft_library() call) happens later, outside the lock, when the
outer face itself is destroyed.

Fix by holding an extra reference on the blob across the locked
FT_Done_Face() call, so it can only reach a zero refcount (and invoke
destroy_ft_library()) after static_ft_library_mutex has been
released. FT_Done_Face() itself remains fully serialized, as intended
by 46644f885d.

Fixes: https://github.com/harfbuzz/harfbuzz/issues/6276
Tests: meson test -C build (260/260 passed); added
test_native_ft_set_funcs_stream_face_no_deadlock to test/api/test-ft.c,
which hangs on unfixed code and passes with the fix. Also verified
against the reporter's original repro.c.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-30 16:47:55 -06:00
nussaibah shaikh 3c8a65ed9d [font] fix signed integer overflow in synthetic_glyph_extents (#6296)
* [font] fix signed integer overflow in synthetic_glyph_extents

synthetic_glyph_extents applies synthetic slant and embolden to a
glyph's extents with plain hb_position_t arithmetic: x_bearing +
width and y_bearing + height in the slant branch, plus the += / -=
shifts in the embolden branch. glyf's contour_bounds_t and the sbix
png-dimension path each clamp x_bearing/width and y_bearing/height to
the full hb_position_t range independently via
hb_clamp_to<hb_position_t>(), so one field can reach INT32_MIN/MAX on
its own and the sum overflows, which is undefined behavior (UBSan
signed-integer-overflow at hb-font.hh:221). Reached from
hb_font_get_glyph_extents when synthetic slant/bold is set and the
glyph has extents but no drawable outline.

This is the sibling of 873dbc1 (scale_glyph_extents), which fixed the
same x_bearing + width overflow in the adjacent function. Accumulate
the slant terms in double and the embolden terms in int64, saturating
each result to hb_position_t with hb_clamp_to, matching that fix and
the copy in hb-ft.cc. Valid in-range extents are unchanged.

Add a regression test in test/api/test-font.c that drives the sink
with INT32-extreme extents; it aborts under the asan/ubsan job without
the fix. Full meson test -C build stays green.

* [font] use int64_t for slant accumulation in synthetic_glyph_extents
2026-09-30 13:04:22 -06:00
artemkulyk 82ec48207b [subset] Drop degenerate VariationDevice records (#6286)
After instancing, GDEF maps all-zero delta rows to
HB_OT_LAYOUT_NO_VARIATIONS_INDEX. copy() still emitted a device with
the out-of-range varidx (0xFFFFFFFF), even though the delta is
already folded into the base value.

Drop the device in that case. gdef_partial_instance is marked
no_fonttools since fonttools keeps the dead device; the
empty_region_vardata and update_def_wght expected outputs are
regenerated.

Tested with: meson test -C build

Assisted-by: opencode
2026-09-29 18:09:44 -06:00
artemkulyk 7cc20b8f70 [subset/cmap] Emit idDelta for zero-delta identity runs (#6284)
serialize_rangeoffset_glyid() treated every zero idDelta as "this
range needs a glyphIdArray", which is what to_ranges() emits for
non-run ranges. A real run with delta 0 (glyph id == codepoint) got
the same treatment and cost two bytes per codepoint.

Only zero deltas are ambiguous. Check those against the mapping and
keep the ones that are genuinely identity as delta ranges.

Adds a subset test with a small hand-built glyf font whose cmap maps
U+0001..U+0007 to gids 1..7.

Tested with: meson test -C build

Assisted-by: opencode
2026-09-29 17:11:17 -06:00
Behdad Esfahbod b3bab62307 [VARC] Clamp component axis coordinates (#6274)
Axis-value variation deltas can push a rounded component coordinate
outside the range of int. Assigning that float to coord_setter then
triggers undefined behavior in the conversion.

Use hb_clamp_to<int>() after rounding, preserving in-range behavior
while saturating extreme values. Add the minimized raster-fuzzer input.

Tested with meson test -C build and the ASan/UBSan raster fuzzer.

Assisted-by: OpenAI Codex
2026-09-21 12:15:48 -06:00
Behdad Esfahbod c87f86eff1 [raster] Widen overflowing scanline accumulators (#6273)
The analytic rasterizer stored every row's area and cover in 32- and
16-bit accumulators. Highly overlapping outlines could exceed those
ranges and trigger signed overflow before coverage was clamped.

Keep compact SIMD accumulators for rows with at most 127 active edges.
Lazily use 64-bit scalar accumulators for denser rows, where the narrow
cover bound no longer holds. Add regressions for area overflow and
cover wrapping.

Tested with meson test -C build, the ASan/UBSan raster API test, all
raster fuzzer corpus chunks, and the supplied reproducer.

Assisted-by: OpenAI Codex <noreply@openai.com>
2026-09-21 11:58:49 -06:00
Behdad Esfahbod bf93d86714 [Unicode 18] Update Unicode data and script support
Update the generated Unicode and language-tag tables for Unicode 18.0.
Add script values for Jurchen, Proto-Cuneiform, and Seal, route them
through USE, and select ideographic baselines for Jurchen and Seal.
Document the new script values and extend Unicode and baseline tests.

Tested with meson test -C build: 278 passed, 1 skipped, 0 failed.

Assisted-by: Codex <codex@openai.com>
2026-09-17 00:37:58 +03:00
Qunxin Liu bf6414323c [subset] Fix empty ClassDef not intersecting class zero (#6262)
* [subset] Fix empty ClassDefFormat2 not intersecting class zero

An empty ClassDef (rangeCount == 0) assigns class zero to every glyph, but
ClassDefFormat2::intersects_class() and intersected_classes() reported no
intersection when glyphs is not empty.

Adds a subset test that fails before and passes after.

* [subset] Fix empty ClassDefFormat1 not intersecting class zero

Same bug as the previous commit, in the format 1 variant. When glyphCount is
zero and startGlyphID is zero, `startGlyph + classValue.len - 1` underflows
to 0xFFFFFFFF, so neither of the two comparisons can be true and class zero
is never reported. (With a nonzero startGlyphID it happens to work.)

harfbuzz always serializes an empty ClassDef as format 2, so this is only
reachable with fonts produced by other tools.

Extends the previous test with a hand-built format 1 variant of the font.
2026-09-15 20:16:33 -06:00
Behdad Esfahbod 92f0aa24f9 [test] Cover static VARC axes without fvar (#6260)
Verify that VARC component coordinates can address axes retained in gvar
when a static font has no fvar table.

Tested with the full Meson test suite.

Assisted-by: Codex <codex@openai.com>
2026-09-14 15:30:54 -06:00
Behdad EsfahbodandClaude Fable 5.1 64e2b53235 [glyf] Charge point loading to the work budget before doing the work (#6256)
The glyf outline budget was only charged after a glyph loaded
successfully: Glyph::get_points() spent 16 units per node up front, and
glyf_accelerator_t::get_points() charged one unit per point only after
the whole tree came back.  A glyph that loaded ~175K points and then
tripped a structural cap (HB_GLYF_MAX_POINTS, edge count) paid for the
nodes but not the points.  Driven from a COLR paint walk through
hb_font_get_glyph_extents(), one such glyph was loaded and thrown away
over 8000 times per session within the budget, ~1.4G point loads.

Charge at the point where the work is attempted instead:

- SimpleGlyph::get_contour_points() takes the budget and charges
  num_points before allocating, clearing, and reading, so truncated or
  later-rejected glyphs pay for the points they allocate.

- Composite levels charge the component subtree size before
  transform_points(), since each nesting level transforms every point
  below it and that multiplication was previously invisible to the
  budget.

The terminal per-point charge for path emission is unchanged.

Local hb-vector-fuzzer run on the testcase: 4.3s -> 0.12s.  Full test
suite passes.  The testcase is added as a fuzz seed.

Fixes: https://oss-fuzz.com/testcase-detail/5714817420427264


Claude-Session: https://claude.ai/code/session_013ksLGe7wUVwbuANqR56YaN

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-10 22:19:47 -06:00
Garret Rieger d2e24847f6 Add null checking and fix memory leak in hb-coretext.cc (#6250)
* Add null checking and fix memory leak in hb-coretext.cc

Assisted by: Gemini

* Add RAII hb_cf_ptr_t to manage coretext object lifetimes.

* Remove HAVE_CORETEXT guard in hb-coretext.hh

hb-coretext.hh will only be included when HAVE_CORETEXT is defined, so no need for the guard.
2026-09-10 14:54:07 -06:00
Behdad Esfahbod 3baafbcb3d [raster] Clip the edge sweep's column walk to the surface (#6251)
* [raster] Clip the edge sweep's column walk to the surface

edge_sweep_row() walked every fixed-point pixel column an edge spans,
even though columns right of the surface contribute nothing and
columns left of it only contribute a cover delta that telescopes into
column 0.  A near-horizontal edge with extreme coordinates could span
~2^24 columns per row, making sweep cost proportional to coordinate
range instead of surface width: the ClusterFuzz testcase took 114s in
a plain release build.

Fold the left-of-surface portion of the walk into a single column-0
cover update, skip the right-of-surface portion, and enter/exit the
per-column loop at the visible window.  Jumping the incremental fy
accumulator by k*delta_fy is exact, since the increment is constant
and the running sums are bounded, so output is bit-identical; verified
by comparing 178 hb-raster renders (draw and paint paths, several
fonts, sizes, and negative-margin crops that clip edges off-surface)
byte-for-byte against the previous code.  The testcase now runs in
0.17s.  Also add it as a fuzz seed.

Fixes https://oss-fuzz.com/testcase-detail/5267980968329216

Assisted-by: Claude Fable 5 <noreply@anthropic.com>

* [raster] Keep an unclipped fast path in the edge sweep

The window clipping added in the previous commit made every
multi-column edge-row pay for the clip setup, measurable as ~1% more
instructions rasterizing all glyphs of NotoSansCJKsc/SourceHanSans-VF
at 256px with hb-raster-all.  Guard it with a two-compare
fully-inside-the-surface check and walk such edges with the original
unclipped code, which is also the everyday case: auto-sized surfaces
always contain their edges.

Interleaved perf-stat A/B (5 rounds, all glyphs at 256px): instruction
overhead drops to +0.24% (CJK) / +0.9% (AwamiNastaliq, tiny workload);
cycles flat to -1.3%, within noise.  Output remains bit-identical on
the 178-render comparison matrix, and the oss-fuzz 5267980968329216
testcase stays at 0.19s.

Assisted-by: Claude Fable 5 <noreply@anthropic.com>

* [raster] Charge column spans in the pixel-work estimate

hb_raster_draw_get_pixel_work() charged each edge only its scanline
span, so a nearly-horizontal edge crossing one pixel row but sweeping
the full surface width cost up to `width` cells while being charged 2
units — the paint path's pixel-budget precharge could undercharge the
sweep by a factor of the surface width.  This is the same blind spot
that let the previous commits' column-walk timeout through the paint
path's precharge.

Charge each edge its column span too, clipped to the surface width the
same way the row span is clipped to its height.  Since an edge is a
straight segment, row span plus clipped column span is a true upper
bound on the post-clipping sweep work.  Normal outlines are barely
affected: flattening yields short segments whose column spans are
commensurate with their row spans, far below the 2^26 budget.

No rendering change: the 178-render comparison matrix remains
bit-identical and the full test suite passes.

Assisted-by: Claude Fable 5 <noreply@anthropic.com>
2026-09-10 14:30:09 -06:00
Behdad Esfahbod 155a9d88e8 [subset] Address VARC review comments
Short-circuit unchanged-index checks and simplify glyph closure to use
one pending set with the output glyph set tracking visited glyphs.

Strengthen retained-glyph-ID coverage by comparing the source and subset
outlines using the original glyph ID.

Tested with: meson test -C build --print-errorlogs

Assisted-by: OpenAI Codex <openai-codex@users.noreply.github.com>
2026-09-10 13:24:14 -06:00
Behdad Esfahbod cfe86ce5e7 [subset] Harden VARC closure handling
Propagate allocation and component-decoding failures from VARC closure
instead of continuing with an incomplete glyph set. Treat malformed VARC
records as dependency-extraction failures as well.

Document VARC dependency edges and exercise subset variation-store
remapping at non-default coordinates.

Tested with:
- meson test -C build
- standalone lean and world syntax checks
- CMake harfbuzz-subset build

Assisted-by: OpenAI Codex <openai-codex@users.noreply.github.com>
2026-09-10 12:11:13 -06:00
Behdad Esfahbod 50046742d7 Merge branch 'main' into varc-subsetting
Resolve the VARC record-decoding conflict by preserving the shared
decoder while threading main's rendering budget through axis and
variation work.

Tests: meson test -C build (277 passed, 1 skipped)

Assisted-by: OpenAI Codex <codex@openai.com>
2026-09-07 12:16:12 -06:00
Behdad Esfahbod 74fc05cd14 [subset] Address VARC review findings 2026-09-07 12:10:33 -06:00
Behdad Esfahbod 46ea946ab4 Merge pull request #6214 from harfbuzz/rendering-work-budgets
[limits] Add rendering work budgets
2026-09-06 16:36:58 -06:00
Behdad Esfahbod db981a8baf [gsubgpos] Preserve concat hazards at end of input (#6238)
The RuleSet fast paths filtered out rules requiring another glyph when
the skipping iterator reached the end of the buffer. Unlike the normal
rule walk, that early return did not record the resulting
unsafe-to-concat range.

Keep the end-of-input optimization, but track filtered rules and mark
their concat hazard before returning. Cover both contextual and chained
contextual rule sets with a five-rule font that forces the fast paths.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-09-05 14:44:39 -06:00
Behdad Esfahbod 92e67ef19f [ot] Preserve pair-positioning and ligature concat hazards
A zero-valued PairPos record can select a different, non-zero record
if the second glyph changes, so keep the pair unsafe to concat even
when no positioning was applied.

Likewise, make the ligature second-glyph digest rejection report the
same hazard as the full ligature walk.

Tests: meson test -C build

Port of https://github.com/harfbuzz/harfrust/pull/465

Assisted-by: OpenAI Codex <codex@openai.com>
2026-09-04 19:55:47 -06:00
Behdad Esfahbod f2d62aaa7d Fix an int overflow
Fixes https://oss-fuzz.com/testcase-detail/4709124282318848
2026-09-04 14:14:49 -06:00
Dylan PulverandDylan Pulver 2688e6c579 [unicode] Treat U+180F FVS4 as Default_Ignorable (#6229)
U+180F MONGOLIAN FREE VARIATION SELECTOR FOUR was added in Unicode
14.0 and has Default_Ignorable_Code_Point=Yes, but
is_default_ignorable() only covered U+180B..180E, so FVS4 was never
hidden and leaked a .notdef into the output.

8c65442069 ("[Unicode 14] Handle U+180F FVS4") added the U+180F case
to _hb_glyph_info_set_unicode_props() and to the Arabic shaper, but
that branch sits inside "if (unicode->is_default_ignorable (u))", so
it has been unreachable since it was written.  Extending the range to
U+180B..180F makes it live.

U+180B..180F are all Default_Ignorable_Code_Point per
DerivedCoreProperties.txt, so the range stays contiguous.

Before, with a font with no Mongolian coverage:

  $ hb-shape Roboto-Regular.abc.ttf -u U+0061,U+180F
  [1=0+1114|0=0@-908,0+0]

Every other default ignorable (U+180B..180E, U+FE00, U+200B) on that
font shapes to [1=0+1114].  After the change U+180F matches them.

Added two cases to mongolian-variation-selector.tests, which already
covered FVS1, FVS2, FVS3 and MVS but not FVS4: U+180F, and U+1810
MONGOLIAN DIGIT ZERO to pin the top of the range so it cannot be
widened by accident.

Tested with "meson test -C build": 254/254 OK, 0 failures.  Restoring
the old U+180B..180E fails in-house 6174/6176, and widening it to
U+180B..1810 fails the same way.

Assisted-by: claude-opus-5

Co-authored-by: Dylan Pulver <dylanpulver@users.noreply.github.com>
2026-09-03 16:26:30 -06:00
Qunxin Liu 14e63042fd [subset] bug fix for BASE table
Embed VarStore offset field when table version is 1.1
2026-09-03 14:23:05 -06:00
Behdad Esfahbod 46644f885d [ft] Serialize access to the static FreeType library (#6225)
FreeType requires face creation and destruction on a shared
FT_Library to be serialized. Protect the lazily-created static library,
its reference count, and its internally-owned faces with a lazy mutex.

Keep caller-owned FT_Library instances outside the new lock, and add a
multithreaded regression test for blob-backed faces and font funcs.

Tests: meson test -C build (272/272 passed)

Fixes: https://github.com/harfbuzz/harfbuzz/issues/6224
Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-31 12:19:10 -06:00
Behdad Esfahbod 7eec305e71 [vector] Cap serialized document size; un-conflate output from outline
The vector work budget charged both outline traversal and serialized
output bytes, and left embedded bitmaps entirely uncharged -- so a COLR
walk with many sweep-gradient or image layers could emit output that the
outline budget never sees, bounded only by the structural per-node caps
times the node count.

Bound the output with a flat document-size cap instead: hb_vector_buf_t
refuses to grow past HB_VECTOR_MAX_DOCUMENT_SIZE (16 MB) and folds that
into in_error(), so every emission site that already checks it -- path
commands, gradient meshes -- stops cleanly, and image embedding is bounded
for the first time.  clear() resets the sticky flag so a context reused
across renders (the documented clear -> paint -> render loop) recovers
after one over-cap glyph.  vector is one glyph per context, so a flat cap
suffices; SVG's whole document and PDF's (assembled through the same
hb_vector_buf_t) share it.

With output bounded structurally, the work budget goes back to pure
outline traversal: drop the per-command byte charge and the sweep-patch
charge so it no longer conflates two different resources.  It is still
needed on its own -- a CFF charstring can do a lot of work while emitting
little output.

Once the cap trips, remaining appends are dropped, so a truncated document
is malformed; render returns it (or null) rather than looping to build
gigabytes, which is the point.

Add a regression test that paints an oversized image and confirms the
document stays bounded and the context recovers on reuse; it fails if the
cap is removed.

Tests: meson test -C build (275/275 passed); the vector COLR regression
seed completes in 0.85s.

Assisted-by: Claude <noreply@anthropic.com>
2026-08-27 17:38:30 -06:00
Behdad Esfahbod dfee0d4380 [raster] Split outline and pixel budgets; drive them via public API
raster-paint reached into the rasterizer through two internal functions:
hb_raster_draw_set_external_work() to inject a shared work counter and
hb_raster_draw_get_edge_work() to read scanline cost back.  Both are gone.

The paint session now carries two budgets for two different resources:

 - The outline budget bounds glyph outline traversal and curve
   flattening.  It is the public draw/paint budget: raster-paint seeds the
   rasterizer with hb_draw_set_budget() before each glyph and reads the
   remainder back with hb_draw_get_budget_remaining(), so a whole COLR
   walk shares one budget without touching rasterizer internals.

 - The pixel budget bounds scanline and fill work, which scales with
   surface area, not outline complexity.  It is charged from the public
   extents of the rendered mask (and other pixel areas) and keeps its
   surface-sized default.  An unlimited outline policy disables it too.

Folding pixel work into the outline budget was why the default had to be
inflated by the surface passes; the two now live apart, so HB_BUDGET_GLYPH
is a pure outline budget and the surface scaling belongs to the pixel
budget.  Standalone hb_raster_draw is unchanged: it draws once, so its
scanline work needs no session budget, only its structural caps.

COLR drives only push_clip_glyph, whose seed/emit/readback is a single
self-contained step, so the aggregate outline budget is always conserved
across a COLR walk.  The push_clip_path_start/end pair spans client draw
calls; like push/pop it must be balanced by the client for the outline
budget to reconcile, and each render is still bounded by the rasterizer's
structural caps regardless.  hb_draw_set_budget() clamps a negative seed
to zero, so outline exhaustion does not latch across glyphs; an empty
mask can then be rendered once more, but that path is bounded by the
pixel budget.

Add a regression test that paints a real multi-layer COLR glyph into a
1x1 surface (unbounded pixel budget) and checks the outline budget both
aggregates the layers' work and bounds the walk.

Tests: meson test -C build (275/275 passed); the raster and gpu COLR
regression seeds complete in 0.40s and 0.44s.

Assisted-by: Claude <noreply@anthropic.com>
2026-08-27 16:53:55 -06:00
Garret Rieger e67dee3f3a Add tests and benchmarks for hb_set_t next_range(). 2026-08-27 15:10:38 -06:00
Behdad Esfahbod 68641b2aed [limits] Consolidate rendering work budgets
Use HB_BUDGET_GLYPH as the common finite default for VARC and the
in-house draw and paint backends. Raster paint retains its surface-size
scaling so large targets still permit a small number of full passes.

Remove redundant exhaustion checks around hb_budget_spend(). A spend
that lands exactly on zero succeeds; only a negative live value latches
exhaustion. Apply the same boundary consistently to postcharged
renderer work and cover the next positive-cost attempt in tests.

The full Meson suite passes, as do the full TSan suite and the three
rendering regression seeds under ASan and UBSan.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-26 18:34:31 -06:00
Behdad Esfahbod 7eab9be024 [cairo] Skip external lock inversion under TSan
Cairo's user-font rendering acquires two internal locks in both
orders. The new nested-rendering regression test exposes that existing
lock-order inversion under ThreadSanitizer, including when run against
an unmodified HarfBuzz.

Keep the end-to-end test enabled normally, but skip that workload when
compiled with TSan instead of suppressing deadlock detection globally.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-26 18:34:02 -06:00
Behdad Esfahbod 15a523bd87 [CFF] Test nested outline budget charges
Exercise CFF work accounting through the public draw-budget callbacks.
Use lower bounds above each parent charstring's flat operator cost so the
CFF1 assertion covers both seac children and the CFF2 assertion covers
proportional blend work.

Keep the interpreter's local cost type consistent with the unsigned spend
interface.

Tests: meson test -C build (275/275 passed)

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-26 17:54:45 -06:00
Behdad Esfahbod 8f3ab5ab87 [cairo] Share work across nested glyph rendering
Cairo's draw callbacks previously received a raw cairo_t, so paint-driven
outline traversals could not share a renderer budget.  Nested color glyphs
also construct fresh HarfBuzz paint contexts while populating the same
scaled-font glyph cache.

Attach a finite budget owner to the scaled font and let each draw/paint
context borrow it.  Recharge only for the outermost glyph callback, expose
the budget callbacks on both function sets, and charge emitted path and
nested color-glyph work.  Exercise the original vector timeout seed through
the Cairo user-font renderer.

Tests: meson test -C build (275/275 passed)

Assisted-by: OpenAI Codex <codex@openai.com>
2026-08-26 17:51:34 -06:00