Merge pull request #1715 from simoncozens/hhea-aliases

[ttLib] Add aliases for renamed entries in hhea table
This commit is contained in:
Cosimo Lupo 2019-09-10 16:24:13 +02:00 committed by GitHub
commit 272a156fc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -35,6 +35,19 @@ class table__h_h_e_a(DefaultTable.DefaultTable):
dependencies = ['hmtx', 'glyf', 'CFF ']
# OpenType spec renamed these, add aliases for compatibility
@property
def ascender(self): return self.ascent
@ascender.setter
def ascender(self,value): self.ascent = value
@property
def descender(self): return self.descent
@descender.setter
def descender(self,value): self.descent = value
def decompile(self, data, ttFont):
sstruct.unpack(hheaFormat, data, self)

View File

@ -126,6 +126,13 @@ class HheaCompileOrToXMLTest(unittest.TestCase):
len([r for r in captor.records
if "Table version value is a float" in r.msg]) == 1)
def test_aliases(self):
hhea = self.font['hhea']
self.assertEqual(hhea.ascent, hhea.ascender)
self.assertEqual(hhea.descent, hhea.descender)
hhea.ascender = 800
self.assertEqual(hhea.ascent, 800)
hhea.ascent = 750
class HheaDecompileOrFromXMLTest(unittest.TestCase):