Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@cmyr
Copy link
Contributor

@cmyr cmyr commented Aug 13, 2025

I'm dealing with a situation where open corner erasure is producing a cubic segment where all the points are equal, which is subsequently falling through the conversion to quadratics.

This handles that situation naively, with a branch; actually improving the robustness of the numerical code is an exercise for someone else.

Dealing with a situation where open corner erasure is producing a cubic
segment where all the points are equal, which is subsequently falling
through the conversion to quadratics.

This handles that situation naively, with a branch; actually improving
the robustness of the numerical code is an exercise for someone else.
@cmyr cmyr marked this pull request as draft August 13, 2025 22:01
@cmyr
Copy link
Contributor Author

cmyr commented Aug 13, 2025

i'm not sure about this patch, it's causing a bunch of other failures I need to investigate...

@behdad
Copy link
Member

behdad commented Aug 13, 2025

which is subsequently falling through the conversion to quadratics.

How does it fail?

@behdad
Copy link
Member

behdad commented Aug 13, 2025

Maybe add a failing test first.

@cmyr
Copy link
Contributor Author

cmyr commented Aug 14, 2025

the test case included here fails if you run it against main.

@behdad
Copy link
Member

behdad commented Aug 14, 2025

I suggest the following fix:

diff --git a/Lib/fontTools/cu2qu/cu2qu.py b/Lib/fontTools/cu2qu/cu2qu.py
index c0d4cf947..42c8f3983 100644
--- a/Lib/fontTools/cu2qu/cu2qu.py
+++ b/Lib/fontTools/cu2qu/cu2qu.py
@@ -273,6 +273,8 @@ def calc_intersect(a, b, c, d):
     try:
         h = dot(p, a - c) / dot(p, cd)
     except ZeroDivisionError:
+        if a == b == c == d:
+            return a
         return complex(NAN, NAN)
     return c + cd * h

@anthrotype
Copy link
Member

closing in favour of #3904

@anthrotype anthrotype closed this Aug 14, 2025
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