opentype.js
opentype.js copied to clipboard
Character path missing commands at smaller sizes
Using the latest master branch, I'm seeing an issue where a path command is being dropped when rendering a certain character. If I increase the font size, the issue is not present, which makes me suspect there's some kind of rounding going on that causes this issue.
I've created a reproduction here comparing the current NPM release of opentype.js with a current build from the main branch.
Rendering this S character from Bodoni font at size 72 - all is good.
At size 53 it seems to be missing the final command and is drawing a diagonal line to close the path instead of a vertical one
Also noticed that trying a much smaller size (in this case 3) it's completely wrong
Can you please check the console to see if there appear any errors?
I see errors related to the platform (stackblitz) but after it's loaded I can clear the console, reload the preview and no errors come up. I have also validated this behaviour in nodejs and produced the same result
Opentype v2.0 post-optimization seems to have flaws.
Explicit optimization options should fix the problem
const d = path.toPathData({
optimize: false,
decimalPlaces: 3,
flipY: false,
});
My assumption: the optimization checks for coinciding control point coordinates after rounding – for smaller font-sizes this will result in more commands being dropped.
Ideally the flipY default should be changed to false or the y-axis flipping shouldn't happen before (in the command parsing)
However, the above options won't be compatible with V1.3 API. I you can do without variable font support you should probably stick with v1.3.4