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
Traverse when there is no layer list #2441
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from fontTools.misc.testTools import getXML, parseXML, FakeFont | ||
from fontTools.misc.testTools import getXML, parseXML, parseXmlInto, FakeFont | ||
from fontTools.misc.textTools import deHexStr, hexStr | ||
from fontTools.misc.xmlWriter import XMLWriter | ||
from fontTools.ttLib.tables.otBase import OTTableReader, OTTableWriter | ||
|
@@ -687,6 +687,33 @@ def test_splitMarkBasePos(): | |
] | ||
|
||
|
||
class ColrV1Test(unittest.TestCase): | ||
def setUp(self): | ||
self.font = FakeFont(['.notdef', 'meh']) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Four space indentation please |
||
|
||
def test_traverseEmptyPaintColrLayersNeedsNoLayerList(self): | ||
colr = parseXmlInto(self.font, otTables.COLR(), | ||
''' | ||
<Version value="1"/> | ||
<BaseGlyphList> | ||
<BaseGlyphPaintRecord index="0"> | ||
<BaseGlyph value="meh"/> | ||
<Paint Format="1"><!-- PaintColrLayers --> | ||
<NumLayers value="0"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @khaledhosny @rsheeter hm, a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that indeed the case. The glyph in question is <svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 130.0 1500.0" width="130.0" height="1500.0">
<defs/>
</svg> |
||
<FirstLayerIndex value="42"/> | ||
</Paint> | ||
</BaseGlyphPaintRecord> | ||
</BaseGlyphList> | ||
''') | ||
paint = colr.BaseGlyphList.BaseGlyphPaintRecord[0].Paint | ||
|
||
# Just want to confirm we don't crash | ||
visited = [] | ||
paint.traverse(colr, lambda p: visited.append(p)) | ||
assert len(visited) == 1 | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
import sys | ||
sys.exit(unittest.main()) |
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.
We use four space indentation