-
Notifications
You must be signed in to change notification settings - Fork 13
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
Expose and fix broken processing of bbox for components whose transform is more than scale and transform #1050
Conversation
cce9792
to
0c25b6d
Compare
// The transform we get here has changed because it got turned into F2Dot14 and i16 parts | ||
// We could go get the "real" transform from IR but ... this seems to match fontmake so far |
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.
the 'real' transform from source or IR doesn't actually matter any more, it's the one that's stored in the glyf table that matters for bbox computation, that's what fonttools TTGlyph.recalcBounds() does (and ufo2ft uses the same method on the compiled TTGlyphs when building the glyf table).
RawGlyph::Composite(composite) => Some((*gn, composite)), | ||
RawGlyph::Simple(..) | RawGlyph::Empty => None, | ||
}) { | ||
let bbox = bbox_of_composite(&glyph_order, &glyphs, glyph, Affine::IDENTITY)?; |
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.
you went for a recursive traversal instead of iterative one. I'm ok with it (fonttools does the same), but I was wondering, even though unlikely, should you prevent from a component cycle triggering an infinite recursion? Python has a max recursion depth after which it raises an exception. Does Rust protect you as well?
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 think for glyphs sources at least we already check against component cycles when we propagate anchors, see glyphs-reader's propagate_anchors.rs (depth_sorted_composite_glyphs)
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.
Let me take confirmation of no cycles as a follow-on. I have the vague notion we might already do it but I'll double-check.
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.
affine: Affine, | ||
) -> Result<Option<Rect>, Error> { | ||
// For simple scale+translate transforms, which seem to be common, we could just transform a bbox | ||
// Let's wait to see if that pops out in a profile and do the simple solution for now |
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.
Let's wait to see if that pops out in a profile
did you actually try to profile before/after this? I suggest filing an issue
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.
Good idea, #1061
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.
LGTM with minor comments
Simplified reproduction of problem impacting Luxurious Roman (
python resources/scripts/ttx_diff.py https://github.com/googlefonts/luxurious-roman#sources/Luxurious-Roman.glyphs
)This appears to be due to fontc assuming it can simply apply the component transform to the control box when in fact it needs to transform the points and compute the control box of the new points. https://codepen.io/rs42/pen/wvVqVPL?editors=1000 sketches the impact of transformation for the new test font.
Reproduced in simplified test that now passes. Luxurious Roman is now identical when ttx_diff'd locally.