-
Notifications
You must be signed in to change notification settings - Fork 51
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
Close open corners in UFO #663
Conversation
Of course the tests are going to fail, because I'm living in the future and GitHub Actions isn't. |
This is causing some problems with fontmake and certain variable fonts. Trying to track it down. |
The heuristic @anthrotype suggested in googlefonts/fontmake#288 was
Unfortunately that doesn't deal with "fat" open corners like this one: where the intersections are at (t1=0.46, t2=0.13) and (t1=0.86,t2=t2=0.53). I guess one approach would be to reorder things and run RemoveOverlap first, to get rid of this kind of open corner, leaving only the more simple ones. But that doesn't work in the general case as RemoveOverlap does unhelpful things to "outside" corners, putting them into a separate contour: So we either need to
|
The open corner processing is only done for outside corners. That means it only does sorting if the previous and next point is on the left of the line segment (as seen from that segment). |
I don't understand this. For the open corner at the bottom, the "previous point" is the start point, right? (Where the 2 is) And the "next point" is the other selected point? They are on different sides of the line segment. |
I might have confused the direction. But both selected nodes are on the same side of the line going through the two points on the bottom (this segment goes from right to left, so the selected points are on the right of that line (when you look RTL)) |
If both are on the right (not left) side when looking in the direction of the short line segment. |
Ah, ok, when the short line segment is aligned clockwise. Thanks, I’ll try working with that. |
I use this function:
and if both points are NOT left of the line, and the both t vales are below 0.5. |
Inside corners will be dealt with by RemoveOverlaps
(Not my test failure - pip-compile is being too strict and pip is being stupid about resolving dependencies.) |
Specifically, the current release of ufolib2 hard-requires fontTools 4.19.0 and we need 4.20.0. We need a new release of ufolib2 to unblock. (Or just stop using pip-compile which is creating too-strict dependency chains.) |
You sure? Where did you see that. In setup.cfg, ufoLib2 only seems to require fonttools >= 4.0.0: https://github.com/fonttools/ufoLib2/blob/1201353d31ce463b13ac12cd12253c4d5a18bded/setup.cfg#L29 you should be able to re-pip-compile the requirements with
that was to make the test runs more predictable. I'm ok if you want to ditch that and keep all deps open-ended and install latest. It means you may find yourself having to deal with sudden unrelated breakages in the middle of your PR |
I already did that in fab5d27.
Hmm, no, I'm not sure. Something is pulling in 4.19.0 as you can see in the test failure. But pip isn't very good at telling me what it is. |
Ack, it's the |
OK, that failing test now is mine, but I don't know how to fix it. We are adding a ufo2ft filter on export to UFO, but I am not sure how that should be round-tripped. |
Please update the requirements files with the newest pip-tools to avoid needless diffs. |
Thanks, I'll try to get to reviewing this this week... out of curiosity, are there use cases for this pen outside a Glyphs context? I wonder if FontLab implements this differently. |
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.
Seems fine to me.
Is it maybe worth making it work on multiple paths at once (i.e. be able to process all contours of a glyph and output trimmed ones without having to re-instantiate the pen between each)?
oh, does Fontlab also have similarly "open corners"? |
elif len(seg) == 4: | ||
self.outpen.curveTo(*seg[1:]) | ||
|
||
if self.is_closed: |
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 self.is_closed
should be reset at the end, before a new contour is drawn with the same pen, otherwise it stays True
I understand this behaviour is the default in Glyphs.app, however I'm a bit concerned that this filter will then be enabled for all .glyphs sources that are built via fontmake, especially given that the segment-segment intersection code in fonttools bezierTools is quite recent and does not have a complete test suite. |
Yes, one can. But one can also argue that this is a mistake and counterintuitive. The expected behaviour is that fonts produced by glyphsLib and fonts produced by Glyphs look the same. Currently they don't, which is why we have designers opening issues saying that fontmake is making their fonts look horrible, and why we have to tell people not to use open corners in fonts they submit. If the problem is that the fontTools code doesn't have a good enough test suite, let's fix that problem, but that's not this problem. We shouldn't need to enable an optional flag to get expected behaviour. The program should do what's expected by default. |
FontLab does this, it's called "looped corners", but it's hidden behind a setting: Font Info > Other Values > Contour Properties > Unfill looped corners. |
@moyogo cool, so it works the same way but more user-configurable |
Should the erase open corner filter be merged in ufo2ft instead? |
If fontlabLib existed, then yes, absolutely it makes sense to put this at the next level in the pipeline. But it doesn't. (Well, it does, it's called babelfont. ;-) So for practical purposes it is only Glyphs which uses open corners. |
I guess it doesn't matter where it is if I want to use it in a UFO workflow, since fontmake requires glyphsLib anyway. |
Discussed here: googlefonts/fontmake#288 (comment) |
So is the Propagate Anchors Filter or the Transformations Filter, yet they are in ufo2ft because it's a useful filter to have in a variety of workflows. There are open corners in Noto Sans Georgian UFO sources for example. FontLab can still export UFOs to be used in fontmake. I don't mind having filters in glyphsLib, I just don't understand what's the logic for that exception. |
yeah, but that's because it was designed inside Glyphs.app then converted to UFO. I don't think there's any native UFO editor that allows one to draw/view these so-called "open corners". It's a font-editor-specific feature, a Glyphs.app-ism, hence it lives in glyphsLib. If it were to become something that is more widely used in UFO-based workflows then we may reconsider moving this to ufo2ft proper. |
@schriftgestalt how does Glyphs.app handle Sofia Sans's kgreenlandic in the DSFix layer? Moved aside to show the contour: |
@schriftgestalt, I'm confused by this. In this case: the t value of the intersection on both line segments is < 0.5, so that's detected as an open corner. OK, that makes sense. But in this case: the t value of the intersection on the selected line segment is way > 0.5, but it's still detected as an open corner! |
this is the actual code:
So if one of the edges id smaller than 0.3, it will still do it. |
Aha! Thank you! |
Requires fonttools/fonttools#2192 to be merged. Fixes #255 and googlefonts/fontmake#288