Skip to content

[compatibility] Normalize contour points before comparing - #1173

Merged
cmyr merged 2 commits into
mainfrom
compat-checker-start-point
Sep 14, 2026
Merged

cmyr merged 2 commits into
mainfrom
compat-checker-start-point

Conversation

@cmyr

@cmyr cmyr commented Sep 10, 2026

Copy link
Copy Markdown
Member

Been looking at the various cases on crater where fontmake fails and fontc doesn't, and came across this.

CompatibilityChecker walks masters index-by-index over the raw UFO point list. This is not the same logic used by the point pen in fontTools, which rotates the point list so that it ends on the first on-curve point (see https://github.com/fonttools/fonttools/blob/82cd560fd9/Lib/fontTools/pens/pointPen.py#L186-L188 ).

This meant that the CompatibilityChecker would reject curves that were actually compatable, when two masters had serialized the same point list with a different start point.

This makes CompatibilityChecker match the rotation logic of the point pen, which means fontmake can now compile a number of fonts that it would previously fail on, such as Exo, Raleway-Italic, and RobotoMono-Italic.

Note that for a contour that really is incompatible, the reported point index is now in normalized rather than glif order.

CompatibilityChecker walks masters index-by-index over the raw UFO point
list. This is not the same logic used by the point pen in fontTools, which
rotates the point list so that it ends on the first on-curve point (see
https://github.com/fonttools/fonttools/blob/82cd560fd9/Lib/fontTools/pens/pointPen.py#L186-L188
).

This meant that the CompatibilityChecker would reject curves that were
actually compatable, when two masters had serialized the same point list
with a different start point.

This makes CompatibilityChecker match the rotation logic of the point
pen, which means fontmake can now compile a number of fonts that it
would previously fail on, such as Exo, Raleway-Italic, and RobotoMono-Italic.

Note that for a contour that really is incompatible, the reported point
index is now in normalized rather than glif order.
@anthrotype

anthrotype commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

we should not apply this rotation unconditionally.

cu2qu rewrites the glyph through the segment pen (so it actually rotates) only when a cubic was converted or reverse_direction is True. When fontmake passes --keep-direction or --ttf-curves keep-quad (or keep-cubic) the TTGlyphPointPen keeps the raw contour points' order, so a start-point mismatch is a real interpolatable incompatibility.

varLib then does not error in this case but simply warns "glyph has incompatible masters; skipping" and the VF ships with empty gvar glyph with no variations. The keep-direction/keep-quad exists exactly so that point indices stay put (e.g. for manual VTT hinting workflows where that matters).

You could add a normalize_start_points kwarg (default True), and at run_from_designspace pass True only when we aren't emitting TTF, or when ttf_curves.convertCubics and reverse_direction are both on.

--keep-direction with the default --ttf-curves cu2qu would still flag today's #875 false positives for the glyphs that do contain cubic curves (cu2qu does rotate those); but I don't think a per-glyph "modified iff any cubic" would be worth it.

the reported point index is now in normalized rather than glif order

maybe say "point N (counting from the first on-curve point)" so it isn't read as a glif index

Make the normalization behaviour controlled by a flag, so that we can
more closely control when it runs, ensuring that the
CompatibilityChecker is matching the behaviour used to generate the
actual contours for interpolation.

@anthrotype anthrotype left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cmyr
cmyr merged commit 92f6ea7 into main Sep 14, 2026
18 checks passed
@cmyr
cmyr deleted the compat-checker-start-point branch September 14, 2026 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ERROR:fontmake.compatibility – compatibility checker is maybe overzealous picky about start points

2 participants