Commit Graph
2865 Commits
Author SHA1 Message Date
Khaled Hosny 86e7473f0d [ot] Add hb_ot_fetch_number()
Similar to hb_ot_fetch_bits() but for signed numbers.

The only tags so far are for font bounding box from head table.

Fixes https://github.com/harfbuzz/harfbuzz/issues/6110
2026-07-31 04:31:26 +03:00
Khaled Hosny 6e67c5feed [ot] Add hb_ot_fetch_bits()
For fetching various bit fields scattered around OpenType tables. Many of
these are legacy or unreliable, but applications might need them for
various legacy reasons.

Fixes https://github.com/harfbuzz/harfbuzz/issues/1920
2026-07-31 04:31:26 +03:00
Khaled Hosny 9d7bba088a Try to fix msan bot (#6124)
* [test/fuzzing] Skip hb-depend-closure-parity without GLib

It depends on GLib unlike the other fuzzers.

* [ci] Build the msan bot without external dependencies

We don’t care about msan errors in code that is not ours, and some
libraries like GLib are not built with memory sanitizers in mind.

* [ci] Don't pipe sanitizer test output

The pipe was masking meson exit status, and it was redundant anyway
since the sanitizer output is is already symbolized and demangled.

* [COLR] Fix integer overflow in get_extents

Use to_glyph_extents(), which guards against this.

Update test expectation since we now round instead of truncate.
2026-07-30 19:02:25 -06:00
Behdad Esfahbod dcb18ae6d0 Merge pull request #5767 from harfbuzz/avar2-instancing
Avar2 instancing
2026-07-30 14:50:34 -06:00
Khaled Hosny 6b6f0d9770 [GPOS] Apply mark-attachment cross-direction offsets immediately
Fixes https://github.com/harfbuzz/harfbuzz/issues/4596

See the issue for more details.

Instead of deferring mark positioning to the end of GPOS application, we
now apply cross-direction offsets (y-direction in horizontal text)
immediately and keep applying main-direction (x-direction in horizontal
text) as before.

This is still not 100% compatible with DirectWrite or Core Text (they
apply both directions immediately), but enough to fix the reported
issue.

Based on Behdad’s patch below, but fixes the Noto Nastaliq regression by
resolving the base offset through the whole cursive attachment chain
since cursive offsets are relative the previous glyph and get finalized
only at end of GPOS:
https://github.com/harfbuzz/harfbuzz/issues/4596#issuecomment-2276300688

The remaining failure is not a regression, the new expectation now match
DirectWrite and Core Text.

The tests include a subsetted bug font, as well as two constructed fonts
where curs lookup come before mark ones, once with kern before mark and
with kern after mark, to show that lookup order affects y but not
x-direction.
2026-07-30 23:27:22 +03:00
Behdad Esfahbod 23a0aa4746 Merge branch 'main' into avar2-instancing 2026-07-30 12:20:25 -06:00
Behdad Esfahbod 9af18b22f4 Merge pull request #6113 from behdad/codex-review-pr-5733
Dependency Graph Review Fixes
2026-07-30 12:00:42 -06:00
Behdad Esfahbod 07b0407cc7 Merge pull request #6098 from harfbuzz/marklig-multiple-subst
Fix mark attachments after decomposition then ligation
2026-07-30 11:57:18 -06:00
Behdad Esfahbod c5eda499b4 Merge branch 'main' into codex-review-pr-5733 2026-07-30 11:40:20 -06:00
Behdad Esfahbod 25fc94439a Merge pull request #5733 from skef/depend-draft-pr
OpenType font dependency graph support
2026-07-30 11:12:48 -06:00
Behdad Esfahbod f26e0cd4ed [instancer] Fix HVAR partial instancing for map-less advance mappings (#6070)
* [instancer] Don't dedup VarStore rows when not optimizing

as_item_varstore dropped duplicate delta rows even with optimize=false,
where varidx_map is left empty and callers rely on original
VariationIndex values staying valid.  HVAR/VVAR subsetting uses that
mode when the source table has an implicit (map-less) advance mapping:
any two glyphs sharing identical deltas shifted every following row, so
the synthesized identity map pointed at wrong rows and past the end of
the VarData — advances silently froze or took neighbors' deltas when
partially instancing such fonts (e.g. Source Han fonts).

Fixes https://github.com/harfbuzz/harfbuzz/issues/6068

* [subset] Drop identity advance maps for map-less HVAR/VVAR sources

When the source table uses implicit glyph-id indexing, the subsetter
synthesized an advance DeltaSetIndexMap whose content was the identity
over every output glyph — equivalent to the implicit indexing it
replaced, just bigger.  Recognize that case in is_identity () and keep
the output map-less, like fontTools does.  Sources that carry a real
map keep one, preserving their form; truncated maps don't qualify since
glyphs past their end share the last value.

retain-num-glyphs expected files regenerated: NotoSansJP-VF.subset.otf
is map-less, and its redundant identity map is now dropped (verified
against fontTools output).

* [test/subset] Test partial instancing of map-less HVAR

ImplicitHVAR.ttf carries an HVAR with implicit (map-less) advance
indexing and deliberately duplicated delta rows, the combination that
broke before the row-dedup fix: rows shifted or fell off the end of the
rebuilt VarData and advances silently froze.  Expected outputs are
cross-checked against fontTools varLib.instancer + subset.
2026-07-29 11:29:23 -06:00
nussaibah shaikh 8c9307b59a [raster] clamp coordinates before converting to int (#6090)
* [raster] clamp coordinates before converting to int

the transformed glyph extents and the flattened segment endpoints are floats derived from int32 inputs and can land far outside the int range, so the conversions were undefined and the extent subtraction overflowed on top of that. saturate through a shared helper and widen the subtraction.

* [raster] generalize int32 saturating cast into hb_clamp_to<>

Move the raster-local hb_raster_clamp_to_int32 helper into hb-algs.hh
as a generic hb_clamp_to<T> that saturates a floating-point value to
the range of any integer type, and use hb_clamp_to<int32_t> at the
three raster call sites.

Signed-off-by: nussaiba shaikh <nussaibah@bugqore.com>

---------

Signed-off-by: nussaiba shaikh <nussaibah@bugqore.com>
2026-07-29 02:59:29 -06:00
Behdad Esfahbod da7f951ef0 Add more hb_barrier()s in switches (#6106)
Fixes https://github.com/harfbuzz/harfbuzz/security/advisories/GHSA-pmg2-m89x-pc6j
2026-07-27 19:20:18 -06:00
Khaled Hosny f3dea1e602 [subset] Add HB_SUBSET_FLAGS_CFF_IDENTITY_CHARSET
When set and subsetting a CID-keyed CFF font, the output charset is
written as identity: CID = new GID.
2026-07-27 22:12:16 +03:00
Khaled Hosny 6cc6d89e05 [GPOS] Count decomposed pieces as one ligature component
Non-first pieces of a MultipleSubst now add no extra component, so a
decomposed glyph absorbed into a ligature counts as the single component
it started as, and its marks attach where MarkBasePos would.

Part of https://github.com/harfbuzz/harfbuzz/issues/4969
2026-07-25 13:35:41 +03:00
Khaled Hosny a49431bcf9 [GPOS] Attach mark to first component of MultipleSubst in MarkLigPos
Do what MarkBasePos already does, so the backward search skips the
leftover pieces of a decomposition instead of giving up on them.

Fixes https://github.com/harfbuzz/harfbuzz/issues/4969
2026-07-25 13:35:28 +03:00
Sai Asish Y cce964cb4f [ot-tag] guard against NULL language in hb_ot_tags_to_script_and_language (#6085)
hb_ot_tag_to_language returns NULL for HB_OT_TAG_DEFAULT_LANGUAGE, and hb_language_to_string returns NULL for it, so the script-suffix path called strlen on a NULL pointer whenever the primary script tag did not match the input. Skip the suffix construction when there is no base language string and leave the default (NULL) language in place.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
2026-07-21 18:47:36 -06:00
nussaibah shaikh 53900fd388 [gpu] bound clip depth in push_clip_path_end (#6073)
push_clip_path_end wrote clip_stack[clip_depth] without the
HB_GPU_PAINT_MAX_CLIP_DEPTH check that push_clip_glyph and
push_clip_path_start both apply. clip_depth can be pushed past
the fixed 3-entry clip_stack, so closing a clip path while the
stack is full writes a pending_clip_t past the array. Guard it
like the sibling clip pushes.
2026-07-21 18:45:53 -06:00
nussaibah shaikh 387ab23f7f [raster] Reject non-finite texel coords in hb_raster_paint_image (#6082)
The range test guarding the bilinear sampler is comparison-based, so NaN
coordinates pass it and reach (int) floorf() in
hb_raster_sample_bilinear_premul, where only x1/y1 are clamped.  The
determinant guard has the same shape, so a transform that overflows to
infinity is accepted and 1/inf turns inf * 0 into NaN.
2026-07-21 18:40:41 -06:00
Qunxin Liu 2c875edbb6 [subset-repack] bug fixes (#6088)
* [subset-repack] fix potential out of bounds accesses

make sure we create a deep copy of the object before we mutate

* [subset-repack] fix is_shared(): only check real parents

* [subset-repack] add tests

* [subset-repack] apply AI proposed change

* address review comments

* [subset-repack] no need to duplicate shared liga_sets beforehand

Since we now would create a memory copy of the object before mutating
it, I think checking and duplicating shared liga_sets is not needed.
2026-07-21 11:49:06 -06:00
Behdad Esfahbod fc85680fec Revert "[subset-repack] bug fixes (#6077)"
This reverts commit 0b590d6b54.
2026-07-21 10:59:48 -06:00
Qunxin Liu 0b590d6b54 [subset-repack] bug fixes (#6077)
* [subset-repack] fix potential out of bounds accesses

make sure we create a deep copy of the object before we mutate

* [subset-repack] fix is_shared(): only check real parents

* [subset-repack] add tests

* [subset-repack] apply AI proposed change

* address review comments

* [subset-repack] no need to duplicate shared liga_sets beforehand

Since we now would create a memory copy of the object before mutating
it, I think checking and duplicating shared liga_sets is not needed.
2026-07-21 10:55:43 -06:00
Nussu06 1737bce456 [subset] bound cvar tuple data length in calculate_cvt_deltas 2026-07-18 07:25:19 -06:00
Nussu06 9de7e9d563 [paint] pass color_glyph its own user_data
The dispatch wrapper handed the callback user_data->push_clip_glyph
instead of user_data->color_glyph, so a client registering both
callbacks with different contexts got the wrong pointer on every
COLR glyph.
2026-07-17 11:43:34 -06:00
Garret Rieger d7861576ae More fixes for review comments. 2026-07-14 16:26:49 -06:00
Garret Rieger 2725565dab Address review comments. 2026-07-14 16:26:49 -06:00
Garret Rieger 99380f0e44 Add new hb_subset_input_to_command_line_or_fail().
This generates an equivalent hb-subset command line string for a given subset input.

Assisted by gemini.
2026-07-14 16:26:49 -06:00
Behdad Esfahbod 4fbbe7ae4f [ot-font] Invalidate vertical origin cache on scale change
The vertical-origin cache stores scaled y-origin values, but it was
validated against serial_coords. Changing only the font scale leaves
serial_coords unchanged, so hb_font_set_scale() could keep serving stale
vertical origins.

Validate scale-dependent OT font caches against the full font serial and
check that serial before using the batched vertical-origin callback. Add
an API regression that changes y_scale on one font and verifies the
vertical origin is recomputed.

Testing:
meson compile -C build test/api/test-ot-face
meson test -C build test-ot-face --print-errorlogs
meson test -C build --suite api --print-errorlogs

Fixes: https://github.com/harfbuzz/harfbuzz/issues/6066
Assisted-by: OpenAI Codex
2026-07-14 14:02:38 -06:00
Behdad Esfahbod 88e09bb1dc Merge pull request #4710 from harfbuzz/cff2-instancing-try2
Trying to partial-instance CFF2
2026-07-14 14:02:20 -06:00
Behdad Esfahbod 41ec50d54b [subset] Include serialize API from subset header
The subset umbrella header already carries the public subset API, but it
missed hb-subset-serialize.h even though the serialize symbols are part
of the subset section. Include the serialize header from hb-subset.h so
users can get the API through the top-level subset header.

Keep hb-subset-serialize.h directly includable for compatibility, but
emit a diagnostic asking users to include hb-subset.h instead. Update the
local repacker tests to use the umbrella header and verify the API is
available there.

Testing: meson compile -C build test/api/test-subset-repacker test/fuzzing/hb-repacker-fuzzer
Testing: meson test -C build --suite api
Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-07-14 12:01:38 -06:00
Behdad Esfahbod c6c9c7c53f [test] Bound depend parity fuzzer runtime
The depend closure parity Meson test ran 1024 random cases per font over
large chunks. That made a single test spend excessive time repeatedly
walking huge cmap data, and the Noto Nastaliq fonts currently spend tens
of seconds or more in contextual GSUB dependency graph construction
before parity comparisons even start.

Cache the unicode-to-glyph map per font, select codepoints with one
linear pass over the cmap, and avoid glyph-starting non-GSUB tests for
huge-cmap fonts. Limit the Meson parity workload to a smaller fixed
sample and skip the two known Nastaliq graph-construction outliers until
that algorithmic path is made fast enough for the default test suite.

Testing: meson test -C build depend-fuzzer-chunk-7 depend-closure-parity-chunk-0
Testing: meson test -C build --suite api
Testing: meson test -C build

Assisted-by: OpenAI Codex
2026-07-14 11:56:05 -06:00
Behdad Esfahbod 77256e876b [depend] Initialize test layout tag filter
The dependency test passes layout_tag to find_dependency() as an
in/out parameter. Initialize it to HB_TAG_NONE so the helper treats it
as an output slot instead of filtering by an indeterminate stack value.

Testing: meson test -C build --suite api

Assisted-by: OpenAI Codex
2026-07-14 11:21:16 -06:00
Khaled Hosny e2588968ae [COLR] Emit fill_glyph for glyph clips with a solid paint
Detect the fill-glyph pattern in the COLRv1 graph: a PaintGlyph whose
child is a (Var)PaintSolid, and emit a single fill_glyph instead of
push_clip_glyph + color + pop_clip.
2026-07-12 22:20:21 +03:00
Khaled Hosny b4ed968183 [test/paint] Test the fill_path callback 2026-07-12 19:36:15 +03:00
Khaled Hosny 9ab56e8678 [vector] Implement fill_glyph callback
Fill the glyph shape directly. This simplifies the SVG/PDF output and
fixes the SVG clipping issue with COLRv0 layers and large scale, as
there is no clip now at all.
2026-07-08 20:30:03 +03:00
Khaled Hosny f7a8ef5022 [vector] Fix PDF MediaBox orientation
The MediaBox negated the y-range like SVG viewBox does, but the SVG
output is wrapped in scale(1,-1), and PDF content is emitted y-up.
2026-07-08 20:28:53 +03:00
Khaled Hosny a1b0b0046c [test/vector] Test painting a COLRv0 glyph at a large font scale
Add a test for painting a COLRv0 glyph at large scale. The output shows
the glyph clipped. We will fix this in the next commits.
2026-07-08 20:28:40 +03:00
Khaled Hosny 04f7a60bc4 [draw] Promote quadratic curves to cubics in double precision (#6057)
The fallback quadratic-to-cubic promotion works in single precision.
This results in different rounding values for different architectures.
Promote in double precision instead, which rounds deterministically.

Add a PDF test that exercises this, and make the test runner handle PDF
expectations.

This also effectively reverts d4511648db
2026-07-08 11:11:16 -06:00
Behdad Esfahbod d287ee3ee2 [ft] Fix get_table_tags returning no tags on streaming faces
_hb_ft_get_table_tags() (used for FT faces created over a custom stream,
i.e. when ft_face->stream->read is set) did

    if (!table_count) return population;
    else *table_count = 0;
    ...
    end_offset = hb_min (start_offset + *table_count, population);

zeroing *table_count before using it as the requested buffer size, so
end_offset collapsed to start_offset, the copy loop never ran, and
hb_face_get_table_tags() always reported zero tags (and wrote none).

Restructure to match the CoreText / face-builder / default backends: keep
the caller's *table_count, check the start_offset + *table_count sum for
overflow, clamp to the table population, then copy.  Also guard the copy
on table_tags so a NULL output array (count-only query) is handled.

The existing FT test used FT_New_Memory_Face, whose in-memory face routes
through the default blob table-tags path and never exercised this
callback.  Add a streaming-face variant (FT_Open_Face with a read stream)
that does; it failed (count 0 vs 3) before this fix.

Assisted-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 01:08:45 -06:00
Behdad Esfahbod 706a2ba8d3 [ot] Guard remaining list-getter output arrays against NULL
Following GHSA-v5mv-8hhw-vff8, sweep the rest of the public "list getter"
APIs for the same defect: a NULL output array passed with a non-NULL count
on a populated table wrote through the NULL pointer and crashed (SIGSEGV).
These output params are not all annotated nullable, but the crash is
reachable from public C APIs and is a straightforward DoS, so guard the
write on the output pointer consistently (matching hb_color_line_get_color_stops
and the fixes in the previous two commits).  When the output is NULL the
getter now just returns the total count.

Getters hardened:

  - MathKern::get_entries              (hb_ot_math_get_glyph_kernings)
  - MathGlyphAssembly::get_parts       (hb_ot_math_get_glyph_assembly)
  - MathGlyphConstruction::get_variants (hb_ot_math_get_glyph_variants)
  - IndexArray::get_indexes            (hb_ot_layout_language_get_feature_indexes,
                                        hb_ot_layout_feature_get_lookups, ...)
  - RecordListOf::get_tags             (hb_ot_layout_table_get_script_tags,
                                        _get_feature_tags, _get_language_tags, ...)
  - AttachList::get_attach_points      (hb_ot_layout_get_attach_points)
  - LigGlyph::get_lig_carets           (hb_ot_layout_get_ligature_carets)
  - fvar get_axis_infos / get_axes_deprecated / get_instance_coords
                                        (hb_ot_var_get_axis_infos, hb_ot_var_get_axes,
                                        hb_ot_var_named_instance_get_design_coords)
  - OpenTypeOffsetTable / CoreText / face-builder get_table_tags
                                        (hb_face_get_table_tags)

Extend test/api/test-ot-nullable-output.c with table-tags, fvar axis-info
and MATH kerning cases; each crashed before this change.

Assisted-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 00:53:56 -06:00
Behdad EsfahbodandClaude Opus 4.8 d75c58a2e4 [ot] Fix NULL-deref when nullable output arrays are passed to list getters
Several public "list getter" APIs document their output array as nullable
(pass NULL to just query the total count without storing anything), but
their implementations gated the copy only on the count pointer:

    if (count)
    {
      + source.sub_array (start_offset, count)
      | hb_sink (hb_array (out, *count));   // writes through out even if NULL
    }

Passing a non-NULL count with a NULL output array on a populated table
therefore wrote through the NULL pointer and crashed (SIGSEGV).

Gate each copy on the output pointer as well (the same idiom already used
by hb_color_line_get_color_stops: "if (count && out)").  This is a no-op
when the output array is non-NULL and restores the documented behaviour of
returning the total count when it is NULL.  Affected getters:

  - hb_ot_color_palette_get_colors            (CPAL)
  - hb_ot_color_glyph_get_layers              (COLR v0)
  - hb_ot_meta_get_entry_tags                 (meta)
  - hb_aat_layout_get_feature_types           (AAT feat)
  - hb_aat_layout_feature_type_get_selector_infos (AAT feat)
  - hb_ot_layout_feature_get_characters       (GSUB cvXX)
  - hb_ot_layout_lookup_get_glyph_alternates  (GSUB aalt)

Add test/api/test-ot-nullable-output.c exercising each route with a NULL
output array; every case crashed before this change.

Fixes: GHSA-v5mv-8hhw-vff8
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 00:28:35 -06:00
Behdad EsfahbodandClaude Opus 4.8 9072836ef5 [vector-pdf] Fix indexed-PNG tRNS soft-mask dimension overflow
hb_pdf_build_indexed_smask() computed its buffer sizes with unchecked
32-bit arithmetic:

    unsigned raw_len = (width + 1) * height;
    ...
    out->resize (width * height);

width/height come straight from the attacker-controlled PNG IHDR (the
vector-PDF path re-parses IHDR itself and does not clamp dimensions,
unlike sbix).  For width = height = 65536, (width + 1) * height wraps to
65536 and width * height wraps to 0.  A crafted IDAT inflating to the
wrapped raw_len passes the length check, the mask buffer is resized to
zero, and the per-pixel loop then writes through out->arrayZ[y*width+x]
and reads past raw -- an out-of-bounds write / NULL-page store and crash.

Reject zero/degenerate dimensions and use hb_unsigned_mul_overflows()
for both (width + 1) * height and width * height before allocating,
sizing the inflate, and indexing.  This bounds every subsequent
raw + y*(width+1) and out->arrayZ[y*width+x] access.

Add a CBDT regression seed embedding a 65536x65536 indexed PNG with a
tRNS chunk; it reaches the soft-mask builder through
hb_font_paint_glyph -> CBDT::paint_glyph -> hb_pdf_paint_image and
crashed pre-fix under ASAN/UBSan at hb-vector-paint-pdf.cc:617.

Fixes: GHSA-gmjm-qc3c-qfp8
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 00:16:00 -06:00
Behdad EsfahbodandClaude Opus 4.8 9a55008395 [vector-pdf] Fix PLTE chunk-length wrapping OOB read in PNG parser
The PNG chunk-bounds check in hb_pdf_paint_image() used wrapping
32-bit unsigned arithmetic:

    if (pos + 12 + chunk_len > len)
      break;

A large attacker-controlled chunk_len (e.g. 0xFFFFFF30) wraps
pos + 12 + chunk_len below len, so a truncated PLTE chunk passes the
check.  The oversized plte_len is then trusted during palette
serialization in add_xobject_png_image(), reading far past the input
buffer -- an out-of-bounds read and deterministic crash.

Rewrite the bounds checks to be non-wrapping, relying on the invariant
pos <= len (len >= 8 is checked earlier): gate the loop on
len - pos >= 12 and reject a chunk with chunk_len > len - pos - 12.
This keeps pos <= len across pos += 12 + chunk_len and makes every
in-loop read (chunk header and chunk payload) provably in bounds.

Add a regression seed font that embeds a malformed indexed PNG with an
oversized PLTE length via sbix.  It reaches the vector-PDF paint path
through hb_font_paint_glyph -> sbix::paint_glyph -> hb_pdf_paint_image
and crashed pre-fix under ASAN at hb-vector-paint-pdf.cc:222; it now
renders cleanly.

Fixes: GHSA-9m78-3jcg-57f2
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 00:08:05 -06:00
Behdad Esfahbod 88645fc252 [test/subset] Exercise vsindex machinery in CFF2 partial instancing
Add AdobeVFPrototype_vsindex.otf (already used by test/api): two
VarData subtables with distinct region sets and a charstring-level
vsindex, covering VarData pruning/renumbering, vsindex remapping and
the re-emitted charstring prefix.
2026-07-03 22:53:13 -06:00
Behdad Esfahbod 33738aeda9 [subset/cff2] Harden partial instancing per review
- Dissolve private-dict blends of VarDatas unused by any retained
  charstring: under retain-gids, fdmap keeps FDs of hole glyphs the
  usage pass never scanned, and their dicts were rewritten against a
  dead transform.
- Take the partial path even when the store has regions but no
  VarData subtables; the verbatim-copy fallback emitted a region list
  whose axisCount contradicted the subsetted fvar (OTS-rejected).
- Make the usage pass honor drop-hints, so VarDatas referenced only by
  hint blends don't survive as bloat.
- Require an actual instancing request for the pinned path: a face
  without fvar plus a reused subset input made all_axes_pinned
  spuriously true.
- Error-compensate the fold rounding across private-dict operators:
  most blended dict values are delta-encoded, so independently rounded
  folds accumulated in the decoded absolutes (blue zones drifted by
  ~0.5 per element); now every absolute is within 0.5 of exact.
- Clarify HB_SUBSET_FLAGS_DOWNGRADE_CFF2 doc: it applies to fully
  pinned instancing.

Expected test outputs regenerated for the private-dict rounding
change.
2026-07-03 22:53:03 -06:00
Behdad Esfahbod f24bb86c95 [test/subset] Add CFF2 partial-instancing tests
Range limiting, pin-one-keep-one, a moved default, and axis dropping,
on AdobeVFPrototype.  Expected outputs are hb-subset's own (fontTools
TTX comparison does not apply to CFF2 charstring encodings); they were
verified geometrically against both the original font and fontTools
varLib.instancer output at a grid of locations in the kept ranges.
2026-07-03 21:39:55 -06:00
Behdad EsfahbodandClaude Opus 4.8 dfa9711dc9 [test] Add avar2 self-contained axis tests
Make the coordinate comparison tag-based (self-contained pinned axes
are removed from the instance entirely; their baked contribution is
validated by the rendering checks) and the expected axis count
parametric.

New subtests: pinning opsz (NO_VARIATION_INDEX) off its default drops
the axis and bakes its constant final coordinate; pinning wdth combined
with a wght range restriction drops wdth while wght keeps offset
compensation (including wdth's constant push on wght's final
coordinate, re-added as a free-axis bias). The pin-at-default subtest
now expects wdth to be removed rather than kept hidden.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-03 18:57:00 -06:00
Behdad EsfahbodandClaude Opus 4.8 7c87fea07e [test] Add avar2 variation-culling tests
Extend TestAvar2Instance.ttf with a HIDDEN parametric axis XTRA
(driven by wght through a new avar2 delta row, final coord spanning
[-0.2, +0.3]), a gvar table for 'A' (tuples on XTRA inside and outside
the reachable range, on wght, and on GRAD), and an HVAR table with
matching regions.

The new culling subtest restricts wght to 300:400:500 and checks, over
a grid of retained locations, that final normalized coordinates AND
rendering-level outputs (advance width, glyph extents) match the
original font, and that the instanced gvar and HVAR shrank. The
moved-default subtest also gains rendering checks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-03 18:57:00 -06:00
Behdad EsfahbodandClaude Opus 4.8 37b92ed336 [test] Add avar2 partial-instancing differential tests
Add TestAvar2Instance.ttf, a 1.6KB fontTools-built avar2 font with five
axes (wght, wdth, GRAD, XOPQ, opsz), interior avar v1 breakpoints on
wght, XOPQ and opsz, a wght delta row driven by wdth, a single delta
row shared by GRAD and XOPQ (driven by wght), wdth and opsz mapped to
NO_VARIATION_INDEX, and opsz's default near its axis minimum (so a
far-moved default makes the retained avar v1 segment steep in the new
space, the quantization-limited regime for offset compensation).

test-subset-avar2.c checks that a partial instance produces the same
final normalized coordinates (hb_font_get_var_coords_normalized: fvar
+ avar v1 + avar v2) as the original font at the same user-space
location, within 2 F2Dot14 units (5 for the steepest case, chosen one
unit below what dropping the interior-breakpoint collection produces,
verified by mutation testing), over grids of locations including the
exact kink positions. The eleven subtests cover: same-default and
moved-default restriction (both directions), shared-varIdx rows
(restricted, pinned, and both restricted), pinning at and off the
default, a pinned axis driven by a free axis, NO_VARIATION_INDEX axes
(fresh VarData creation), interior avar v1 breakpoints, and steep
moved-far-from-min defaults.

The subtests abort without the three preceding fixes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-03 16:35:49 -06:00
Behdad Esfahbod 6a0bcf4318 [VARC] Fix test fonts glyphDataFormat (#6046) 2026-07-02 14:01:19 -06:00