Commit Graph
21418 Commits
Author SHA1 Message Date
Behdad Esfahbod ced6e141a7 [var] Embed gvar accelerator fallbacks
The gvar facade only needs to pick between concrete table
accelerators. Embed the lowercase and uppercase accelerators directly
instead of allocating the selected implementation by hand.

This removes the extra allocation failure path and lifetime helpers,
while preserving the GVAR-first fallback order.

Tested with meson test -C build.

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod d8906a8acd [var] Hide gvar/GVAR selection behind gvar accelerator
Expose only face->table.gvar to clients and let its accelerator
prefer GVAR before falling back to gvar. Keep the concrete table
types for tagged parsing and subsetting, while removing the
separate GVAR face-table slot from callers.

The facade owns the selected concrete accelerator so GVAR still
uses MediumTypes and gvar still uses SmallTypes.

Tested with meson test -C build and local subset-fuzzer target
builds.

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod 16fce0eb2f [var] Avoid odr-use of gvar glyph-count limit
The fuzzer build links static objects with C++11 and odr-used the
static constexpr glyph_count_max member through hb_min references,
requiring an out-of-class definition. Make it a constexpr helper
function instead so no storage definition is needed.

Tested with meson test -C build and local subset-fuzzer target builds.

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod e11011ede8 [ot] Remove core face-table loader variant
The maxp/MAXP facade now carries the only recursion guard that was
needed for face glyph-count loading. The remaining face-table entries
do not need the core table sanitizer special case, so list them with
the regular table macro and drop the extra lazy-loader template
parameter.

Tested with meson test -C build and a no-beyond64k fuzzer target build.

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod d653f4b6f5 [ot] Hide maxp/MAXP selection behind maxp loader
Expose only face->table.maxp to clients and let its accelerator
choose MAXP before falling back to maxp. This keeps the uppercase
table as a tagged concrete type for subsetting while avoiding a second
client-facing face-table slot.

Use a sanitizer context with num_glyphs set to zero, matching core
table loading, so reading maxp/MAXP does not recurse back through
hb_face_t::get_num_glyphs().

Tested with meson test -C build and a no-beyond64k fuzzer target build.

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod c47f89d42b [layout] Keep chained-context coverage counts 16-bit
Chained context format 5 widens the rule-set offsets, but its
rule-set count remains uint16. Likewise, the coverage-array counts in
the shared chained coverage-context body remain uint16 while the
coverage offsets can widen.

Use Array16Of with Types-sized offset entries for those fields.

Tested with: ninja -Cbuild
Tested with: meson test -C build --suite subset
Tested with: meson test -C build --suite shape
Tested with: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod e14529f977 [layout] Keep reverse-chain coverage counts 16-bit
ReverseChainSingleSubst format 2 widens the coverage offsets and
substitute glyph IDs, but the backtrack and lookahead coverage-array
counts remain uint16. Keep both arrays with 16-bit counts while using
the selected Types offset width for their entries.

Tested with: ninja -Cbuild
Tested with: meson test -C build --suite subset
Tested with: meson test -C build --suite shape
Tested with: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod 943760c5cc [var] Support GVAR subsetting
GVAR uses the same structure as gvar, but its glyphCount field is
uint24. Keep the shared gvar_GVAR body typed by the OpenType size
family, use that field width when serializing glyphCount, and route
uppercase GVAR through the subsetter.

Tested with: ninja -Cbuild
Tested with: meson test -C build --suite subset
Tested with: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod 0a846ce2a7 [ot] Rename maxp shared table body
Rename the templated maxp/MAXP shared body to maxp_MAXP to match the
existing gvar_GVAR naming pattern.

Tested with: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod 2b6bcb2f48 [ot] Support 24-bit VORG format
The VORG tag is unchanged, but version 2 widens both
numVertOriginYMetrics and VertOriginYMetrics.glyphIndex to uint24.
Template the VORG body over the OpenType size family and keep the
public VORG type as a version-dispatch wrapper.

Subsetting preserves the source VORG major version, so version 1 stays
16-bit and version 2 stays 24-bit.

Tested with: meson test -C build --suite subset
Tested with: meson test -C build in-house test-ot-extents-cff
Tested with: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod a45917c004 [ot] Add MAXP table support
Templatize the existing maxp implementation over the OpenType size
family and add MAXP as the 24-bit numGlyphs variant. Prefer MAXP when
loading the face glyph count, expose it through the face table list, and
keep MAXP as MAXP during subsetting.

The earlier order-sensitive failure reproduced only with libharfbuzz and
libharfbuzz-subset built against different lazy-loader table orders.
After rebuilding both libraries with MAXP next to maxp, the reproducer
and full suite pass.

Tested with: meson test -C build --suite subset
Tested with: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod 1f3ab6b96f [hmtx] Remove old beyond-64k metric extension
Drop the hmtx/vmtx paths that encoded and read synthetic advance data past the 16-bit glyph range. Keep the existing count bookkeeping and use the same behavior as the HB_NO_BEYOND_64K path for glyphs beyond the normal metrics data.

Tested with: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod af36122656 [face] Stop deriving glyph count from loca
Use maxp as the face-wide glyph count source and remove the old beyond-64k fallback that inferred glyph count from the loca table length. The glyf accelerator still keeps its own loca-derived bounds separately.

Tested with: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod 2d65bbf462 [colr] Add PaintGlyph2 format
The beyond-64k spec adds COLR PaintGlyph2 format 33, matching
PaintGlyph format 10 but using a 24-bit glyph ID.

Template PaintGlyph over the glyph ID type and dispatch format 33
through the existing sanitize, subset, closure, and paint paths.

Testing: meson test -C build test-ot-color test-paint test-subset-colr
Testing: meson test -C build --suite subset
Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod 0bf6733c0e [graph] Reject non-v1 GSUB/GPOS graph roots
The repacker graph sanitizer accepted non-v1 GSUB/GPOS roots
because GSUBGPOS::get_size() returns only the version field size
for unsupported major versions. Graph specialization then still
consulted the numeric version and could read the v1.2 lookupList2
field from a too-small fuzz object.

Require version major 1 before using GSUB/GPOS graph-specific
lookup discovery.

Testing: meson test -C build test-repacker test-classdef-graph
Testing: meson test -C build --suite subset
Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod e93552fa09 [layout] Allocate full GDEF v1.4 header
GDEF subsetting started by allocating only the base v1.0 header
and then tried to extend the final v1.4 tail field directly.
That jumps over the intervening v1.4 offsets and can trip the
serializer head assertion under CIFuzz.

Keep the existing incremental allocation for v1.2/v1.3 so GDEF
downgrade snapshots can still trim those tails, but allocate the
full version-dependent header before writing v1.4 offsets.

Testing: meson test -C build --suite subset
Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod 93d2aa8ec9 [layout] Do not re-extend allocated v1.2 featureVars
GSUB/GPOS v1.2 subsetting allocates the full version-dependent
header before writing the 32-bit list offsets. That already includes
the v1.1 featureVars field.

Avoid extending featureVars a second time after child list serialization
has advanced the serializer head, which can assert under CIFuzz.

Testing: meson test -C build --suite subset
Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod 014ae09d44 [layout] Allocate full GSUB/GPOS v1.2 header
GSUB/GPOS subsetting started by allocating only the base v1.0
header, then jumped directly to lookupList2 for v1.2 tables. That
can pass a pointer beyond the serializer head to extend_min(), which
asserts under fuzzing.

Keep the old incremental allocation for v1.0/v1.1 tables so feature
variation downgrade snapshots can still trim the tail, but allocate
the full version-dependent header before writing v1.2 offsets.

Testing: meson test -C build --suite subset
Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod 336d65cdab [graph] Guard beyond-64k classdef graph tests
The default build has HB_NO_BEYOND_64K enabled, so serializers reject
glyph IDs above 0xffff with an integer-overflow error. Keep the high
glyph ClassDef size checks for beyond-64k builds only.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod 90dcc405a8 [layout] Serialize coverage and classdef from fresh iterators
Coverage and ClassDef serialization use one pass over the input to
choose the compact format, then a second pass to write the selected
format. Reusing the same iterator for both passes left some iterator
types exhausted, which surfaced in test-classdef-graph for high glyph
IDs after the 24-bit forms were added.

Take a fresh iterator view for the sizing pass and another for the
actual serialization.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod 813558d2e9 [gpos] Template mark attachment arrays
MarkBasePos, MarkLigPos, and MarkMarkPos format 2 use nested
MarkArray2, BaseArray2, LigatureArray2, and Mark2Array2 tables
with 24-bit counts and offsets in different combinations.

Template the shared mark records and anchor matrices so format 1
continues to use SmallTypes while format 2 uses the widths specified
for the beyond-64k layout forms. Keep the subset graph wrappers bound
to their existing 16-bit forms.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod cdc1ca9edf [layout] Sanitize lookup lists with their offset width
LookupOffsetList is parameterized by offset width, but its sanitizer
called the 16-bit offset-list base explicitly. Dispatch through the
actual List16OfOffsetTo base so 32-bit lookup-list views use the right
offset element type.

Tested with: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod a86c5a2847 [gpos] Fix subset MarkMark row count
MarkMarkPos subsetting can drop empty Mark2 rows after filtering the
original coverage. Serialize the Mark2Array row count from the kept
coverage instead of the original candidate iterator length.

Tested with: meson test -C build --suite subset
Tested with: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod feb5d2186b [layout] Name GSUB/GPOS typed offset views
Move the repeated typed offset casts in GSUBGPOS sanitize and subset
paths behind local accessors. The table fields keep their existing
reader-facing types, while lookup and feature subsetting can ask for
the specialized list views they need.

Tested with: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:52 +02:00
Behdad Esfahbod ef538ebafa [graph] Clarify 24-bit layout splitter policy
Update graph splitter comments to document that 24-bit layout formats
are intentionally left unsplit because their relevant offsets are
already widened.

Testing: not run; comment-only change.

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 8a7a5e9baa [graph] Account for 24-bit ClassDef size estimates
Update the ClassDef and Coverage size estimator used by graph
splitting to derive glyph and range widths from the included glyphs
instead of assuming 16-bit table formats. Keep ClassDef size selection
aligned with the serializer heuristic, including class breaks and the
fact that class zero is not encoded in ClassDef tables.

Add high-glyph test cases that compare the estimator against actual
24-bit ClassDef and Coverage serialization sizes.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod fb91f3be90 [graph] Support 24-bit Coverage sanitization
Template the graph Coverage sanitizers on the layout type width and
dispatch formats 3 and 4 through the MediumTypes variants. This lets
graph sanitization accept 24-bit Coverage tables instead of rejecting
those formats outright.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 5f8d73cbe9 [graph] Support 24-bit ClassDef sanitization
Template the graph ClassDef format wrappers on the layout type width
and dispatch formats 3 and 4 through the MediumTypes variants. This
lets graph sanitization accept 24-bit ClassDef tables instead of
rejecting those formats outright.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 5968649782 [layout] Fix 24-bit ClassDef serialization
Select ClassDef formats 3 and 4 by updating the local format value
before storing it in the serialized table. The previous code adjusted
the union format field before overwriting it, so 24-bit glyph IDs could
still serialize as format 1 or 2.

Use the Types integer width for format 1/3 class values and preserve
the matching format tag for empty ClassDef tables.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 6b074f7c4f [gsub] Use typed reverse-chain coverage offsets
Pass the typed coverage offset arrays directly to the shared
backtrack and lookahead match helpers. The skipping iterator already
knows how to extract the underlying 16- or 24-bit offset storage from
OffsetTo arrays, so the reverse-chain apply path does not need raw
pointer casts.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 17946e4648 [gsub] Template alternate and ligature serialization glyph IDs
Allow the builder-style alternate and ligature serialization helpers
to accept either 16- or 24-bit glyph ID array wrappers. Keep one
GlyphID template parameter across each helper and leave the existing
format selection unchanged.

The ligature component-list wrapper is still passed by reference so
its cursor advances across LigatureSet serialization; the glyph data
itself remains read-only when callers pass const array views.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 9e753418a3 [gdef] Document nested beyond-64k offset widths
The GDEF v1.4 header widens several top-level offsets, but not every
nested table changes its own internal offset widths. Document that
AttachList keeps Offset16 internals when reached through attachList2,
and that LigGlyph keeps Offset16 caret value offsets when reached
through LigCaretList2.

Testing: ninja -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod c9e16b1e64 [layout] Widen context coverage offset handling
Use Offset32-based coverage helper dereferences so decoded coverage
offset values work uniformly for both 16- and 24-bit encoded arrays.

Feed ContextFormat3_6 coverage arrays through the layout Types integer,
and template ChainContextFormat3 over Types so its coverage arrays follow
the same structure. The spec adds a sequence-context format 6, but no
corresponding chained-context coverage format; keep chained-context
dispatch limited to formats 4 and 5 and document the discrepancy.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 36e349505a [gsub] Support reverse-chain format 2
Template the reverse-chain single substitution format over the layout
Types and dispatch format 2 for beyond-64k fonts.

Format 2 uses 24-bit coverage offsets and substitute glyph IDs. Keep
the lookahead count 16-bit as specified, even though its coverage
offsets are widened. Match coverage offsets through an Offset32 object
so both 16- and 24-bit offset arrays keep normal null-offset handling.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod dc5d58a9d7 [gsub] Widen format 2 subtable arrays
Use the layout Types array and offset forms for GSUB subtables that
gain 24-bit coverage-indexed arrays in the beyond-64k formats.

This widens SingleSubst substitute arrays, MultipleSubst sequence
offsets, AlternateSubst alternate-set offsets, LigatureSubst
ligature-set offsets, and the LigatureSet offsets to Ligature
tables while preserving the nested 16-bit counts required by the
spec.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 373ff59709 [layout] Widen chained context rule-set offsets
Use the layout Types for chained context rule-set arrays and
ChainRuleSet offsets. For class-based formats, use a named
ChainClassRuleSet wrapper so the 24-bit surrounding offsets do not
leak as a second template argument at the call site.

This brings ChainedSequenceContextFormat4 and Format5 in line with
the spec's 24-bit counts and offsets while keeping class-rule
payloads in their 16-bit class-value form.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 77acc39460 [layout] Widen sequence context rule-set offsets
Use the layout Types for sequence context rule-set arrays and
RuleSet offsets. For class-based formats, use a named ClassRuleSet
wrapper so the 24-bit surrounding offsets do not leak as a second
template argument at the call site.

This brings SequenceContextFormat4 and Format5 in line with the
spec's 24-bit counts and offsets while keeping class-rule payloads
in their 16-bit class-value form.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 770cc08a26 [layout] Support sequence context format 6
Template the coverage-based sequence context format over layout
Types and dispatch format 6 through the MediumTypes instance.

This matches the spec's wider coverage-offset variant while keeping
formats 1 through 5 unchanged.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 7978af46e7 [layout] Support GDEF version 1.4 header
Fold the GDEF versioned header fields back into GDEF and select
active offsets from the table version.

Version 1.4 now honors the spec's 32-bit offset2 fields when they
are present.  LigCaretList is templated over layout Types so the
version 1.4 LigCaretList2 layout can use the 32-bit coverage offset,
24-bit glyph count, and 24-bit LigGlyph offsets.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod a1a1002e59 [layout] Fold GSUB/GPOS version handling into header
Move the GSUB/GPOS versioned header fields back into GSUBGPOS
and select the active ScriptList, FeatureList, and LookupList
offsets from the table version.

Version 1.2 now uses the spec's 32-bit offset2 fields when they
are present, while the common list internals remain the existing
16-bit layout structures.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod e9289735f2 [base] Support BaseCoord format 4
Add the BASE BaseCoord format 4 dispatch arm. The format mirrors
format 2, but stores the reference glyph as a 24-bit glyph ID for
fonts with an extended glyph repertoire. Share the implementation
through a Types-templated format pair.

The subsetting path remaps the widened reference glyph in the same
way format 2 remaps its 16-bit reference glyph.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod eb8d87f024 [beyond-64k] Preserve CursivePos format when subsetting
CursivePos format 2 reuses the templated format-1 body with wider
fields. Preserve the source format when serializing subsets so a format-2
subtable is not emitted with a format-1 tag.

Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 4997b9f75c Revert some AI noise
Broke some access that was guarded behind hb_barrier()
2026-06-05 12:34:51 +02:00
Behdad Esfahbod 533452d0d6 [beyond-64k] Update SinglePos / PairPos for latest proposal 2026-06-05 12:34:51 +02:00
Behdad Esfahbod 435a67417e [beyond-64k] Add CursivePosFormat2 2026-06-05 12:34:51 +02:00
Behdad Esfahbod 0932bbc45c [beyond-64k] Update PairPosFormat3 to latest proposal 2026-06-05 12:34:51 +02:00
Behdad Esfahbod 155c19c216 [beyond-64k] Add SinglePos formats 3/4 2026-06-05 12:34:51 +02:00
Garret Rieger 8647a429ce Fix subset fuzzer timeout. (#6019)
https://oss-fuzz.com/testcase-detail/5440786836815872
2026-06-04 04:37:23 -06:00
Khaled Hosny 56feae4035 14.2.1 14.2.1 2026-06-02 14:30:59 +03:00
Behdad Esfahbod 8beb229a4c [gen-tag-table] Generate bytes instead of str in rust output (#6017) 2026-06-02 03:11:23 -06:00