Palette dedup only compared the original colorRecordIndices start.
After subsetting, palettes that differed just in colors that got
dropped keep equal color sequences at different starts, and each got
its own copy of the color records.
Compare the retained colors and reuse the first matching block.
Palettes may share color records; each still exposes the same colors.
Tested with: meson test -C build
Assisted-by: opencode
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>
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
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
* [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.
An avar version 2 table with a NULL varStore offset is legal and maps
like plain v1 — but partial-instancing it used to fail outright, because
the planner errored against the missing store. Rather than falling back
to the v1 instancing path (which rescales every variation store and is
not always bit-exact), keep such fonts on the avar2 path: mapping
entries that don't resolve to a real store row are normalized to
NO_VARIATIONS_INDEX, mirroring runtime get_delta semantics, and offset
compensation creates the needed delta rows on demand in an empty store.
The instance stays version 2 and bit-exact, and consumers that ignore
the v2 tail still see the renormalized v1 segment maps.
Adds a subset test with a null-VarStore variant of the RobotoDelta test
font; the instancing test fails outright without the fix.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* [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.
- 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.
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.
Prior to this change the object id for a vertex in the repacker graph is it's position in the topological ordering. As a result after each sorting the object ids change. This decouples the topological sorting from the object id assignments. A separate ordering list is retained. This simplifies handling around object ids which no longer needs to account for them shifting, and improves performance by eliminating the step of reassigned link object ids after each sort.
Used in conjunction with retain gids, when set the num glyphs from the input font will be preserved. Empty glyphs will be inserted as necessary to maintain the num glyphs value. Put under experimental for now.
Fixes#5281. Does the closure by default, but I've introduced a new flag and option to disable this behaviour since some users may want to get the minimal set if they know they don't need the mirrored variants.
cmap14 subsetting code was not considering variation selectors in the input unicode set when deciding which variant glyphs to keep. This updates subsetting to only keeps variant glyphs if their variation selector code point is in the input unicodes set.
For https://github.com/harfbuzz/harfbuzz/issues/4911
This is to fix file name too long error
tar: harfbuzz-8.4.0/test/subset/data/expected/sync_vmetrics/playwrite_mm.subset.default.retain-all-codepoint.SPED=25,YEXT=520,wght=100-400,slnt=18.iup_optimize.ttf: file name is too long (cannot be split); not dumped
tar: Exiting with failure status due to previous errors