-
Notifications
You must be signed in to change notification settings - Fork 43
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
Don't skip over spacing marks when kerning #720
Conversation
0914e73
to
c0ecee2
Compare
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, thanks!
spacing = [] | ||
if marks: | ||
spacing = [mark for mark in marks if self.context.font[mark].width != 0] | ||
if not spacing: |
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.
How does this work? Many font sources have none spacing marks with +ve advances and rely on the compiler to zero them, would they be considered spacing marks in this context? Or the zeroing would have happened already at this point (but this cide would be noop then)?
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.
If this depends on Glyphs’s “Spacing Combining” sub category, then it probably should have checked for this, checking for glyph width feels like the kind of indirection that comes back to bite you in the rear.
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.
Only non-spacing combining marks are zeroed by the compiler, spacing ones are not and as such have a non zero advance width.
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.
But spacing combining marks do not exist in OpenType nor AFDKO feature files, only in Glyphs, so what happens to sources not coming from Glyphs that happen to have marks with advance widths (which is harmless as the layout engine will be zerowing them for most scripts)?
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.
If your sources say that a glyph has advance width, you should not be surprised when ufo2ft treats it as a glyph with advance width.
(And remember, the change here only affects the very specific case of ignoring marks in kerning between two bases. It doesn't change anything that's already happening or not happening with regard to mark width zeroing.)
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.
spacing combining marks do not exist in OpenType nor AFDKO feature files, only in Glyphs
well, "spacing combining marks" do exist in unicode, general category "Mc", don't they?
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.
If your sources say that a glyph has advance width, you should not be surprised when ufo2ft treats it as a glyph with advance width.
They have the right glyph class, the fact that they have an advance width is irrelevant as the layout engine will zero them when shaping.
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.
spacing combining marks do not exist in OpenType nor AFDKO feature files, only in Glyphs
well, "spacing combining marks" do exist in unicode, general category "Mc", don't they?
But we are not using that here, and it is also irrelevant as OpenType knows only about only one class of mark glyphs and the font sets the glyph class, but we are second guessing its intentions based on a tangentially relevant heuristic. The whole concept of feature writers is broken beyond repair, but adding more surprising exceptions and heuristics tuned for individual fonts is not helping.
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.
Here is a more real example. Some monospace fonts, e.g. DejaVu Sans Mono, give combining marks an advance width (so that legacy systems that require all glyphs in monospace fonts to have the same adcance width would still recognize them as monospace) then zeros the width using GPOS single positioning lookups. Monospace fonts obviously don't need kerning, but this shows a combining mark can have an advance width while not being a spacing combining one.
This reverts commit 87c6881.
Consider the following font:
We want to kern between ka-deva and ra-deva:
But (to do certain bits of OpenType magic) we make highspacingdot-deva a "spacing combining" mark (spacing mark). This is so we can filter it out when doing conjuncts or something like that. (This is slightly contrived, but an analogous situation does exist for many Indic scripts.)
We also want kerning between ka-deva and the mark, so we make a base-mark kern:
But because it's a mark class in GDEF, when we apply base-base kerning, this gets skipped. So with a sequence like
ka-deva|highspacingdot-deva|ra-deva
, the result, with current ufo2ft, is:ka-deva|ra-deva
-250ka-deva|highspacingdot-deva
-150.Instead what we need to do is, rather than filtering out all marks, only filter out non-spacing marks, allowing spacing marks to break the base-base kern, so that only base-mark kerning is applied: