-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
ShapePath: Fix unlinked holes when path has hole on first AND last #24114
Conversation
|
||
const restShapeHoles = newShapeHoles.pop(); | ||
|
||
Array.prototype.push.apply( newShapeHoles[ newShapeHoles.length - 1 ], restShapeHoles ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just newShapeHoles[ newShapeHoles.length - 1 ].push( ...restShapeHoles )
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find both ways hard to read 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind explaining in more detail how the error occurs? TBH, the implementation of ShapePath.toShapes()
is borderline. Before adding more complexity it's important to understand why the code fails. And if the patch can be applied elsewhere.
This problem occurs in the step 1. Shapes first, holes last Holes first, shapes last Holes first, HOLES last If step 1 is fixed to divide all |
I think I remember now. We've discussed a similar problem in #16950. Instead of using I know it's odd importing a separate loader for this task but this is just for testing. If you need a code example, three.js/examples/webgl_loader_svg.html Line 182 in c03a6e8
|
@Mugen87 I tested by patching
// Array.prototype.push.apply( shapes, paths[ p ].toShapes() );
paths[ p ].userData ??= {};
paths[ p ].userData.style ??= {};
paths[ p ].userData.style.fillRule ??= "nonzero";
Array.prototype.push.apply( shapes, SVGLoader.createShapes( paths[ p ] ) ); |
Fixed via #24293. |
Closing. The workaround for this issue is the usage of In the long term, the implementation of |
Related issue: none
Description
When holes on first AND last in the path,
ShapePath.toShapes()
incorrectly ignores the holes.For example, the letter
激
in typeface.json has 5 holes, 1 shape, and 2 holes. The last 2 holes are incorrectly ignored.Expected behavior
Actual behavior
typeface.json