Commit Graph
2 Commits
Author SHA1 Message Date
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
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