Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix extra segment in eraseOpenCorners #1057

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Jan 16, 2025

In the process of porting this functionality to Rust, I've run into a funny issue: in some cases, after erasing corners, the outline generated here contained an extra duplicate point at the beginning.

This error seems to be introduced only for contours where the last segment is a curve, and it is introduced early; even before we start processing, there is an extra segment in the segments list for these contours.

This patch addresses this by changing the logic of closePath to not emit a final line segment if it would be a duplicate, but I'm not totally confident that this is the right approach.


More detail: I believe that what is going on is an interaction between the logic for closePath in eraseOpenContours and the logic in the PointToSegmentPen that is writing into it. That pen is skipping the last LineTo segment in a closed path, trusting closePath to handle it; but by always adding a lineTo in closePath we're inserting extra segments when the last segment wasn't a lineTo.

Another note: this patch is causing a new fontmake failure on one crater font, based on a rounding issue; there's a case where the start/end points are off by an epsilon in one master and not the other, which leads us to add the extra segment in one case. I'm not sure how best I should check this case.. should I strictly be looking for epsilon difference, or would it be okay to check if the points are equal after otround?

In the process of porting this functionality to Rust, I've run into a
funny issue: in some cases, after erasing corners, the outline generated
here contained an extra duplicate point at the beginning.

This error seems to be introduced only for contours where the last
segment is a curve, and it is introduced early; even before we start
processing, there is an extra segment in the segments list for these
contours.

This patch addresses this by changing the logic of closePath to not emit
a final line segment if it would be a duplicate, but I'm not totally
confident that this is the right approach.
@cmyr cmyr force-pushed the erase-corners-extra-segment branch from c8b52b9 to 5f7dca4 Compare January 18, 2025 00:00
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