[varLib] make STAT v1.2, reuse fvar nameIDs
Fixes https://github.com/googlei18n/fontmake/issues/417
This commit is contained in:
parent
6a88c39834
commit
08c30e9fde
@ -169,22 +169,26 @@ def _add_avar(font, axes):
|
|||||||
return avar
|
return avar
|
||||||
|
|
||||||
def _add_stat(font, axes):
|
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:
|
if "STAT" in font:
|
||||||
return
|
return
|
||||||
|
|
||||||
nameTable = font['name']
|
nameTable = font['name']
|
||||||
|
fvarTable = font['fvar']
|
||||||
|
|
||||||
STAT = font["STAT"] = newTable('STAT')
|
STAT = font["STAT"] = newTable('STAT')
|
||||||
stat = STAT.table = ot.STAT()
|
stat = STAT.table = ot.STAT()
|
||||||
stat.Version = 0x00010000
|
stat.Version = 0x00010002
|
||||||
|
|
||||||
axisRecords = []
|
axisRecords = []
|
||||||
for i,a in enumerate(axes.values()):
|
for i, a in enumerate(fvarTable.axes):
|
||||||
axis = ot.AxisRecord()
|
axis = ot.AxisRecord()
|
||||||
axis.AxisTag = Tag(a.tag)
|
axis.AxisTag = Tag(a.axisTag)
|
||||||
# Meh. Reuse fvar nameID!
|
axis.AxisNameID = a.axisNameID
|
||||||
axis.AxisNameID = nameTable.addName(tounicode(a.labelname['en']))
|
|
||||||
axis.AxisOrdering = i
|
axis.AxisOrdering = i
|
||||||
axisRecords.append(axis)
|
axisRecords.append(axis)
|
||||||
|
|
||||||
@ -195,6 +199,10 @@ def _add_stat(font, axes):
|
|||||||
stat.DesignAxisCount = len(axisRecords)
|
stat.DesignAxisCount = len(axisRecords)
|
||||||
stat.DesignAxisRecord = axisRecordArray
|
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
|
# TODO Move to glyf or gvar table proper
|
||||||
def _GetCoordinates(font, glyphName):
|
def _GetCoordinates(font, glyphName):
|
||||||
"""font, glyphName --> glyph coordinates as expected by "gvar" table
|
"""font, glyphName --> glyph coordinates as expected by "gvar" table
|
||||||
|
Loading…
x
Reference in New Issue
Block a user