[varLib] make STAT v1.2, reuse fvar nameIDs

Fixes https://github.com/googlei18n/fontmake/issues/417
This commit is contained in:
Cosimo Lupo 2018-04-16 12:35:30 +02:00
parent 6a88c39834
commit 08c30e9fde
No known key found for this signature in database
GPG Key ID: 59D54DB0C9976482

View File

@ -169,22 +169,26 @@ def _add_avar(font, axes):
return avar
def _add_stat(font, axes):
# for now we just get the axis tags and nameIDs from the fvar,
# so we can reuse the same nameIDs which were defined in there.
# TODO make use of 'axes' once it adds style attributes info:
# https://github.com/LettError/designSpaceDocument/issues/8
if "STAT" in font:
return
nameTable = font['name']
fvarTable = font['fvar']
STAT = font["STAT"] = newTable('STAT')
stat = STAT.table = ot.STAT()
stat.Version = 0x00010000
stat.Version = 0x00010002
axisRecords = []
for i,a in enumerate(axes.values()):
for i, a in enumerate(fvarTable.axes):
axis = ot.AxisRecord()
axis.AxisTag = Tag(a.tag)
# Meh. Reuse fvar nameID!
axis.AxisNameID = nameTable.addName(tounicode(a.labelname['en']))
axis.AxisTag = Tag(a.axisTag)
axis.AxisNameID = a.axisNameID
axis.AxisOrdering = i
axisRecords.append(axis)
@ -195,6 +199,10 @@ def _add_stat(font, axes):
stat.DesignAxisCount = len(axisRecords)
stat.DesignAxisRecord = axisRecordArray
# for the elided fallback name, we default to the base style name.
# TODO make this user-configurable via designspace document
stat.ElidedFallbackNameID = 2
# TODO Move to glyf or gvar table proper
def _GetCoordinates(font, glyphName):
"""font, glyphName --> glyph coordinates as expected by "gvar" table