-
Notifications
You must be signed in to change notification settings - Fork 69
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
Point direction request #43
Comments
I can add a |
By the way, the font that you have linked doesn't have a CFF table. |
Apologies, I assumed it had an OTF table like CFF in it because some of the points are defined in the order expected of the CFF/CFF2 tables. Here's what I believe is happening: Looking at it closer, some glyphs in this font are defined as an affine transform, for example I would appreciate the glyph_source method for where the glyph's outline is sourced from. This would remove some ambiguity. |
Some extra information on point ordering for TrueType fonts: Contours that need to be filled black must have a clockwise direction. If we want to make a white area inside an existing contour we must make the direction of the new contour counter clockwise. Contour direction is determined by seeing in which direction the point index values increase or decrease. Contour direction is from the smaller point index to the larger. The general rule is that the contour direction should be such that "black is on the right". Using the glyph "O" as an example, the outer contour should travel clockwise, and the inner contour counter clockwise. For CFF based contours the direction is exactly the opposite, so contours that need to be filled black must have a counter clockwise direction. |
|
Also feel free to message me on xi.zulipchat.com if you want. |
Very strange. FreeType produces the same outline, but the points order and values are very different. Looks like the problem not in mirroring, but in the second contour points order. I will try to write a tool that will help me with debugging this issue tomorrow. The most interesting part, is that if you export both outlines (ttf-parser one and ft2 one) to SVG, they will be filled equally, while having different points. Here: issue-43-test.zip |
So I've added points enumeration: FreeType: ttf-parser: As you can see, the points order/direction is roughly the same. Looks like FreeType does some slight changes to the output (not rounding). I will have to run FreeType under debugger to figure it out. PS: this is GID 232 without Y mirroring, i.e. as is. |
So in the end, mirroring and direction are the same as in FreeType. Maybe the problem is somewhere else? |
The glyph in question should be 225 'b', which is a transform of 232. Given this is a glyph from the I don't think any solution here is elegant, |
Just as an information. I just downloaded the version from the google fonts directory and this version doesn't seem to have this problem: So it might very well be that the TTF file in the above repository is just plain broken. |
@hasenbanck Yes, that font version doesn't mirror |
@RazrFalcon Your images are upside down, and also both of your comments for 'b' and 'd' have different windings which illustrates the problem. Your 'd' is counter clockwise and your 'b' is clockwise. There's nothing wrong with
You'll need to expose both the glyph source and transforms applied for each contour to handle this correctly downstream, which is kind of a pain. |
All I was able to find is FT_Outline_Get_Orientation, which indeed returns PS: And could you please tone down your demands. This is open source and not a commercial support line. |
Apologies that the last comment came on too strong. I appreciate your work on |
Ok. My point was that there is no bug, if all other libraries are doing the same. Which is still true. |
So Once again, I don't see a bug here. It's a tricky feature with no clear solution. And as far a I can tell, transformations has nothing to with this. You can make such malformed font even without transformations. Also, looks like it's not |
Thank you for the extra information and context on FreeType's solution. I agree this is a malformed font and not a failure on Would the feature request for the glyph source still be reasonable to add in |
Sure, I will add such method. |
I think that this is the right way to do this. I've updated the docs. They mention parsing order now. The problem with Basically, the current implementation is |
I ran into this font which defines and uses glyphs in the
CFF
andglyf
tables: https://github.com/emilk/egui/blob/master/egui/fonts/Comfortaa-Regular.ttfMy rasterizer needs to know the point winding before it can run
outline_glyph
. For TrueType, a counter clockwise contour will always define the outside edge of a filled area, and a clockwise contour will always define the inside edge of a filled area. This is reversed for OpenType fonts.Is there a way to know if for a given
GlyphId
, the glyph is from an OpenType table or TrueType table?The text was updated successfully, but these errors were encountered: