Merge pull request #1599 from khaledhosny/fealib-valuerecord-asfea

[feaLib] don’t write None in ast.ValueRecord.asFea()
This commit is contained in:
Khaled Hosny 2019-05-03 11:20:33 +02:00 committed by GitHub
commit dadec23978
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -1143,6 +1143,12 @@ class ValueRecord(Expression):
elif yAdvance is None and not vertical:
return str(xAdvance)
# Make any remaining None value 0 to avoid generating invalid records.
x = x or 0
y = y or 0
xAdvance = xAdvance or 0
yAdvance = yAdvance or 0
# Try format B, if possible.
if (xPlaDevice is None and yPlaDevice is None and
xAdvDevice is None and yAdvDevice is None):

View File

@ -11,6 +11,10 @@ class AstTest(unittest.TestCase):
statement.append(ast.GlyphName(name))
self.assertEqual(statement.asFea(), r"[\BASE \NULL foo a]")
def test_valuerecord_none(self):
statement = ast.ValueRecord(xPlacement=10, xAdvance=20)
self.assertEqual(statement.asFea(), "<10 0 20 0>")
if __name__ == "__main__":
import sys