-
Notifications
You must be signed in to change notification settings - Fork 479
Add glyf flags bit6 to ttx output #1316
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
Conversation
@@ -263,6 +263,9 @@ def __len__(self): | |||
flagReserved1 = 0x40 | |||
flagReserved2 = 0x80 | |||
|
|||
# These flags are kept for XML output after decompiling the coordinates | |||
keepFlags = flagOnCurve + flagReserved1 |
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.
Shouldn’t flagReserved1
be renamed now? It is no longer a reserved flag in the current version of the spec (OVERLAP_SIMPLE
in https://docs.microsoft.com/en-us/typography/opentype/spec/glyf).
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 point
("on", self.flags[j] & flagOnCurve), | ||
] | ||
if self.flags[j] & flagReserved1: | ||
# Apple's AAT uses flagReserved1 in the first contour/first pt to flag glyphs that contain overlapping contours |
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.
That is an Apple rasterizer feature rather than an AAT-specific one (i.e. not related to layout tables being used).
flags.append(not not safeEval(attrs["on"])) | ||
flag = not not safeEval(attrs["on"]) | ||
if "overlap" in attrs: | ||
f = safeEval(attrs["overlap"]) |
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 would use the same trick as in the line above for the on
flag, by negating twice to obtain a boolean, or just call bool
.
flag = not not safeEval(attrs["on"]) | ||
if "overlap" in attrs: | ||
f = safeEval(attrs["overlap"]) | ||
flag += f * flagReserved1 |
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.
better use "or" bitwise operator instead of "+" here: flag |= f * flagReserved1
let's rename flagReserved1
to OVERLAP_SIMPLE
return re.sub(' ttLibVersion=".*"', '', string) | ||
|
||
|
||
class glyfTableTest(unittest.TestCase): |
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 rest of the tests in this file already use pytest-style tests (with plain assert
statements), I would prefer that over unittest-style tests.. but anyway some tests is better than none, thanks anyway.
Tests/ttLib/tables/_g_l_y_f_test.py
Outdated
font['head'] = newTable('head') | ||
font['loca'] = newTable('loca') | ||
font['maxp'] = newTable('maxp') | ||
font['maxp'].data = self.maxpData |
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.
why do you set data
attribute here? I don't think it's needed
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 thought it was necessary, but actually isn’t. The only important thing is the tables need to be decompiled in the correct order because they depend on each other.
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.
right
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, we can merge after the CI completes
oh .. and what about the similar OVERLAP_COMPOUND flag? Don't we want to expose that too? |
That flag is at least already preserved because components show the flags as hex numbers in ttx: <TTGlyph name="Adieresis" xMin="-6" yMin="0" xMax="1495" yMax="1845">
<component glyphName="A" x="0" y="0" flags="0x604"/>
<component glyphName="dieresis.cap" x="233" y="0" flags="0x4"/>
</TTGlyph> Perhaps we should display all the flags in more human readable form here? |
Right ok. I’d say let’s keep it as is for now |
Thanks! |
Thank you! |
Bit 6 of the flags of the first outline point in a glyph, indicating that there are overlaps in the glyph’s contours, got lost when roundtripping with ttx.
This patch preserves bit 6 in the most simple way, by adding it as an attribute of its contour point:
See issue #730.