Skip to content

cubic_to_quadratic: better handle edge cases when cubic degenerates to a line or single point - #485

Merged
cmyr merged 5 commits into
mainfrom
cu2qu-degenerate-cubics
Aug 18, 2025
Merged

cubic_to_quadratic: better handle edge cases when cubic degenerates to a line or single point#485
cmyr merged 5 commits into
mainfrom
cu2qu-degenerate-cubics

Conversation

@anthrotype

@anthrotype anthrotype commented Aug 18, 2025

Copy link
Copy Markdown
Collaborator

Fixes #484

This is intended to match fonttools/fonttools#3904

In addition to the above fonttools PR which only handles 3 to 4 consecutive cubic control points, in here I also consider intersections when a point is collinear and lies in between the endpoints of the other line.
I think this is a logical consequence if we agree that when there are 3 consecutive equal points at the front/back of cubic bezier then there's an intersection at the common (start/end) point.

kurbo's try_approx_quadratic uses Line::crossing_point method, so I modified that one to behave like that.

…o a line or point

Fixes #484

intended to match fonttools/fonttools#3904

Note the above fonttools PR only handles 3 to 4 consecutive cubic control points, whereas in here I also consider intersections when a point is collinear and lies in between the other two.
@anthrotype
anthrotype force-pushed the cu2qu-degenerate-cubics branch from 8e87a17 to 1968edf Compare August 18, 2025 14:56
@anthrotype
anthrotype force-pushed the cu2qu-degenerate-cubics branch from 77ca97c to d3376d2 Compare August 18, 2025 17:30

@cmyr cmyr 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.

great, thanks cosimo!

@cmyr
cmyr added this pull request to the merge queue Aug 18, 2025
Merged via the queue into main with commit 2124358 Aug 18, 2025
15 checks passed
@cmyr
cmyr deleted the cu2qu-degenerate-cubics branch August 18, 2025 17:34
@behdad

behdad commented Aug 18, 2025

Copy link
Copy Markdown

This is intended to match fonttools/fonttools#3904

Just want to point out that in fonttools we updated the crossing_point function instead of the caller. I understand that might not be desirable here though.

github-merge-queue Bot pushed a commit that referenced this pull request Sep 1, 2025
just realised I didn't update the CHANGELOG.md after #485
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.

3 participants