Skip to content

fix(CFF2): close the last contour when the charstring ends - #244

Open
bluevisor wants to merge 1 commit into
harfbuzz:mainfrom
bluevisor:cff2-close-last-contour-main
Open

bluevisor wants to merge 1 commit into
harfbuzz:mainfrom
bluevisor:cff2-close-last-contour-main

Conversation

@bluevisor

Copy link
Copy Markdown

CFF1 closes the final contour on endchar. CFF2 has no endchar, so cff2::parse_char_string returns with the last contour of every glyph still open: close() is only emitted by a following moveto.

Consumers that close paths themselves don't notice. Ones that don't, like fontdue, fill the open contour as if it ran back to the origin. In practice, every glyph of Haiku's stock NotoSansMonoCJKjp-VF.otf came out as a solid block: 你 has 8 contours but only 7 close() calls. With this change, fontdue's rasterization of 你 from the variable font matches the static NotoSansCJK-Regular.ttc pixel for pixel.

Change: after the top-level charstring is parsed, close the path if a moveto was seen. This mirrors what CFF1 does at endchar.

Tests:

  • The existing CFF2 tests now expect a trailing Z. One of them explicitly documented the open last contour.
  • New test every_contour_is_closed uses two contours. It fails without the fix (… L 100 200 vs … L 100 200 Z ).
  • cargo test and cargo test --release pass.
  • The CI feature-matrix builds all succeed.

I didn't have poly locally. cargo fmt --check on the changed source file is clean.

🤖 Generated with Claude Code

CFF1 closes the final contour on endchar, which CFF2 does not have, so the
last contour of every CFF2 glyph was left open. Rasterizers that don't
close paths themselves (fontdue) fill such glyphs solid; Noto Sans CJK VF
glyphs render as filled boxes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T10:40:26.832662Z cd1a1cb PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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