Commit Graph
16915 Commits
Author SHA1 Message Date
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 cba5f9d10d [docs] Remove stale extended-format comments
Update the cmap format 15 and LookupList2 field comments to match the final
Open Font Format text.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-01 16:50:12 -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 8759f47d64 [subset] Order GVAR after avar2
The avar2 dependency scheduler delayed lowercase gvar until avar had been
subsetted, but omitted the uppercase GVAR companion. Add the same guarded
dependency so extended glyph variations observe the finalized avar2 state.

Tested with the focused avar2 test and the full Meson test suite.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-01 15:57:17 -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 c0bd381bd7 [subset] Serialize 24-bit chained-rule glyphs
Use the chained rule type width for backtrack, input, and lookahead arrays. The hardcoded 16-bit writes truncated extended glyph IDs and shifted the lookup-record array.

Add a byte-level regression covering all three glyph arrays.

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

Assisted-by: OpenAI Codex
2026-10-01 14:15:54 -06:00
Behdad Esfahbod 31d082d84a [subset] Serialize 24-bit sequence-rule glyphs
Use the rule type width when remapping glyph-keyed sequence rules. Writing HBUINT16 truncated extended glyph IDs and misaligned the following lookup records.

Add a byte-level serializer regression for a remapped glyph above 65535.

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

Assisted-by: OpenAI Codex
2026-10-01 14:14:32 -06:00
Behdad Esfahbod 795224e1b5 [layout] Use Offset24 in ChainedSequenceRuleSet2
The extended chained sequence context format uses Offset24 entries in
its inner ChainedSequenceRuleSet2 array.  Propagate the enclosing format
type to that array instead of always selecting the 16-bit offset type.

Add a compile-time size check for the medium rule-set header and first
offset entry.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-10-01 13:32:19 -06:00
Behdad Esfahbod d2e218ac26 [layout] Use 24-bit ClassDef format 3 values
ClassDef format 3 stores startGlyphID, glyphCount, and each class value
as uint24.  Use the medium integer type for the class array, select a
serializable format based on both glyph and class ranges, and keep the
subsetter size estimator in sync.

Test parsing and querying a class value above 65535, and test that the
serializer and size estimator select the matching format.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-10-01 13:29:55 -06:00
Behdad Esfahbod 3a5572ee33 [GDEF] Correct LigCaretList2 header size
Account separately for the 32-bit coverage offset and 24-bit ligature
glyph count.  The previous expression treated both fields as 24-bit and
declared a six-byte minimum instead of the required seven bytes.

Add a compile-time assertion for the extended header size.

Testing: meson test -C build

Assisted-by: OpenAI Codex <codex@openai.com>
2026-10-01 13:23:38 -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
Khaled Hosny eb033319fc 14.5.1 2026-10-01 02:34:38 +03:00
Behdad EsfahbodandClaude Sonnet 5.5 c34f0d97f2 [gpu] Fix 32-bit overflow in hb_gpu_paint_encode() and cap sub-blob bytes (#6301)
* [gpu] Check overflow when summing paint sub-blob sizes

hb_gpu_paint_encode() accumulated the lengths of all sub-blobs into
a 32-bit unsigned without an overflow check, then allocated the
output from the wrapped total.  A COLRv1 font whose paint DAG
revisits a max-size (65535-stop) gradient 4096 times makes the sum
exactly 2^32, so the buffer was tiny while the copy loop wrote the
real data, overflowing the heap.

Use hb_unsigned_add_overflows() for both the sub-blob sum and the
total size, and fail the encode on overflow, as hb_gpu_draw_encode()
already does.

Not added a regression test: triggering it needs ~4 GiB of blobs.
Tests: meson test -C build.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* [gpu] Cap total paint sub-blob bytes

Gradient color-stop blobs (up to 1 MiB each) were unmetered, so a
COLRv1 paint DAG revisiting one thousands of times could force
multi-GiB allocations and copies in a single glyph encode.

Route all sub-blob pushes through hb_gpu_paint_t::push_sub_blob(),
which fails (marking the paint unsupported) once the running total
exceeds 64 MiB.

Tests: meson test -C build.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-09-30 17:17:40 -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
David Corbett d84e253c0f Map fonupa variant to UPPH language system (#6299) 2026-09-30 15:59:36 -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
Matej Smycka 897f2e0e2c Fix/wasm shape features free (#6291)
* [wasm] Fix memory leak inside _hb_wasm_shape()

Correct variable should be freed otherwise memory leaks inside the
container can take place.

* [wasm] extract features ptr to variable for clarity
2026-09-29 17:16:31 -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 EsfahbodandClaude Sonnet 5 873dbc1e32 [font] Fix signed integer overflow in scale_glyph_extents (#6275)
hb_font_t::scale_glyph_extents() computed
extents->x_bearing + extents->width (and the y equivalent) as a
plain hb_position_t (int32_t) addition before scaling to float.

glyf's contour_bounds_t::get_extents() clamps x_bearing and width
independently via hb_clamp_to<hb_position_t>(), so each can reach
INT32_MIN/INT32_MAX on its own for a malformed/adversarial glyf
outline. Their sum can then overflow a 32-bit int, which is
undefined behavior and was flagged by UBSan.

Fix by doing the addition in float, after each term is already
scaled, instead of adding the raw hb_position_t values first.

Reproduced with the OSS-Fuzz hb-raster-fuzzer testcase at
https://oss-fuzz.com/testcase?key=5782717883809792, built locally
with -Db_sanitize=undefined:

  ../src/hb-font.hh:205:28: runtime error: signed integer overflow:
  32 + 2147483647 cannot be represented in type 'int'

Confirmed the UBSan report no longer triggers on that testcase
after the fix, and `meson test -C build` passes in full (278/278,
1 pre-existing skip).

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-23 10:18:44 -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
Kevin Hellemun 0d0b62575f fix(gcc 4.9.4): compilation errors
The current build for v14.5.0 fails to compile on gcc 4.9.4 which is
used on embedded Kobo systems. 

Ref: https://github.com/OGKevin/cadmus/pull/1005

Change-Id: 7a4bec5b5418bd0921b273d8d4a1e79b
Change-Id-Short: spvolnuouvyr
2026-09-21 11:02:29 -06:00
Khaled Hosny 863d3f7787 14.5.0 2026-09-21 00:41:07 +03:00
Garret Rieger 240a7d7b8b Fix incorrect add_object sizes. (#6267) 2026-09-17 18:54:44 -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
egoism d8c712f41c Fix memory leak in graphite2 face shaper unhappy path (#6263) 2026-09-15 21:16:07 -06: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 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 863c53818b [directwrite] Fix cluster mapping OOB access, heap overflow, and UAF (#6252)
In the DirectWrite shaper, vis_clusters was allocated from the scratch
buffer with a static size based on Uniscribe scratch math (glyphs_size).
This caused three memory safety issues:

1. vis_clusters was indexed using log_clusters, which stores user
   cluster IDs rather than glyph indices, allowing arbitrary
   out-of-bounds array access. In DirectWrite, the character-to-glyph
   mapping is returned in clusterMap, not log_clusters.
2. If glyphCount exceeded glyphs_size, the initialization loop
   overwrote past the allocated scratch buffer.
3. buffer->ensure(glyphCount) could reallocate buffer->pos,
   invalidating the scratch-allocated vis_clusters before its values
   were read into info->cluster (use-after-free).

Fix this by allocating vis_clusters dynamically as an hb_vector_t
sized to glyphCount, and correctly mapping clusters using clusterMap
with bounds checks.

Assisted-by: Gemini
2026-09-10 16:12:36 -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 d268a23eeb [subset] Split VARC subsetting into helpers
Move table-specific planning and record rewriting phases out of
VARC::subset() into a dedicated helper.  This leaves the entry point to
coordinate the phases and serialize their results without changing
subsetting behavior.

Tested with: meson test -C build

Assisted-by: OpenAI Codex <openai-codex@users.noreply.github.com>
2026-09-10 12:23:33 -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 5343bf4019 Merge branch 'main' into varc-subsetting
Assisted-by: OpenAI Codex <openai-codex@users.noreply.github.com>
2026-09-10 11:53:30 -06:00
Behdad Esfahbod f5efbbef38 Reapply "[rust] Pin skrifa" (#6248)
This reverts commit 9279d1d1a1.
2026-09-09 12:15:31 -06:00
Behdad Esfahbod 9279d1d1a1 Revert "[rust] Pin skrifa"
This reverts commit b48358db71.
2026-09-09 11:57:38 -06:00
Behdad Esfahbod b48358db71 [rust] Pin skrifa
Build was failing otherwise.
2026-09-09 11:53:21 -06:00
Behdad Esfahbod bc678801ce [subset] Emit a valid empty shared-tuples offset (#6240)
When a gvar table has no shared tuples, point sharedTuplesOffset at the
end of the glyph-variation offsets array, where the empty shared-tuples
array resides, instead of emitting a null offset.

This lets strict consumers retain glyph variations in partially
instantiated fonts with no shared tuples.

Assisted-by: OpenAI Codex <codex@openai.com>
2026-09-08 12:14:02 -06:00
Behdad Esfahbod 9435eaa5fa Merge branch 'main' into varc-subsetting 2026-09-07 14:19:21 -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 edd4f3b4b9 [limits] Restore rendering budget test runtime (#6244)
The unified glyph budget raised outline work limits for VARC, raster,
vector, and GPU rendering to 1 << 26.  Pathological fuzz inputs can
consume that entire allowance, doubling the full test-suite runtime.

Restore the common outline budget to 1 << 24 while retaining the
rasterizer's separate 1 << 26 pixel-work floor.  Precharge raster
scanline work against that pixel budget before rendering so complex
COLR masks cannot do unbounded edge sweeps before their mask area is
charged.

Tests: meson test -C build (276 passed, 1 skipped; 2.82-2.83s)

Assisted-by: OpenAI Codex <codex@openai.com>
2026-09-07 12:09:32 -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