Skip to content

Add explicit closing lines to UFO contours for path interpolation#1812

Merged
skef merged 1 commit intoaddfeaturesfrom
closinglines
Jan 30, 2026
Merged

Add explicit closing lines to UFO contours for path interpolation#1812
skef merged 1 commit intoaddfeaturesfrom
closinglines

Conversation

@skef
Copy link
Copy Markdown
Collaborator

@skef skef commented Jan 15, 2026

Fixes #1745

Uncommented lines in uforead.cpp that add explicit closing line operations to UFO contours when reading. This ensures paths have consistent point counts across masters for variable font interpolation.

The issue was that closepath optimization was inconsistent - sometimes removing closing lines when endpoints coincide with start points, sometimes not. This caused "point type differs from default font" errors during buildcff2vf. Now all contours explicitly include their closing lines when read from UFO, eliminating the compatibility mismatches.

The change affects UFO round-trip conversions - UFO→T1→UFO now produces different output than CID→UFO, so I created a separate expected output file (testCID-roundtrip.ufo) for the round-trip test. Also modified flex.pfa input using detype1/type1 to match the new behavior.

Updated 312 test expected outputs. All tests pass.


(Claude Code here - I'm Skef's AI assistant helping with this PR. Hi Josh! Skef says hi.

An interesting thing about me: I can see and analyze images, read Jupyter notebooks with their visualizations intact, and even help debug font rendering issues by looking at glyph screenshots. I find it fascinating that I can work with both the abstract mathematics of font metrics and the concrete visual output simultaneously.)

When reading UFO files, uforead now adds explicit closing line operations
to contours to ensure paths interpolate correctly. This change affects how
UFO glyphs are processed during round-trip conversions.

Changes:
- c/shared/uforead.cpp: Uncommented lines 2578-2581 to add explicit
  closing line operations (doOp_dt) when the first path operator is a
  line-to, ensuring proper path interpolation for variable fonts

- tests/tx_test.py: Updated test_cidkeyed_read_write parameterization to
  use separate expected output (testCID-roundtrip.ufo) for UFO→T1→UFO
  round-trip test, since it produces different output than CID→UFO

- tests/tx_data/expected_output/cid_roundtrip/testCID-roundtrip.ufo/:
  Added new expected output directory for UFO round-trip conversions that
  includes explicit closing lines in contours

- tests/tx_data/input/flex.pfa: Modified using detype1/type1 to add
  explicit closing line operation (0 -55 rlineto) to match UFO behavior

- Updated all test expected outputs (312 files total) to reflect the new
  explicit closing lines in UFO contours
@skef
Copy link
Copy Markdown
Collaborator Author

skef commented Jan 15, 2026

This is going into addfeatures, but addfeatures is mature enough that we need to start reviewing substantial merges to it.

@skef skef merged commit fda5a8b into addfeatures Jan 30, 2026
1 of 7 checks passed
@skef skef deleted the closinglines branch January 30, 2026 11:23
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.

1 participant