Merge pull request #1242 from anthrotype/stat-1.2

[varLib] make STAT 1.2, and reuse fvar nameIDs
This commit is contained in:
Cosimo Lupo 2018-04-16 13:55:23 +02:00 committed by GitHub
commit 8ee3f016d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 33 deletions

View File

@ -169,22 +169,25 @@ 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 +198,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

View File

@ -494,12 +494,6 @@
<namerecord nameID="273" platformID="1" platEncID="0" langID="0x0" unicode="True">
TestFamily-BlackHighContrast
</namerecord>
<namerecord nameID="274" platformID="1" platEncID="0" langID="0x0" unicode="True">
Weight
</namerecord>
<namerecord nameID="275" platformID="1" platEncID="0" langID="0x0" unicode="True">
Contrast
</namerecord>
<namerecord nameID="1" platformID="3" platEncID="1" langID="0x409">
Test Family
</namerecord>
@ -578,12 +572,6 @@
<namerecord nameID="273" platformID="3" platEncID="1" langID="0x409">
TestFamily-BlackHighContrast
</namerecord>
<namerecord nameID="274" platformID="3" platEncID="1" langID="0x409">
Weight
</namerecord>
<namerecord nameID="275" platformID="3" platEncID="1" langID="0x409">
Contrast
</namerecord>
</name>
<post>
@ -794,22 +782,23 @@
</MVAR>
<STAT>
<Version value="0x00010000"/>
<Version value="0x00010002"/>
<DesignAxisRecordSize value="8"/>
<!-- DesignAxisCount=2 -->
<DesignAxisRecord>
<Axis index="0">
<AxisTag value="wght"/>
<AxisNameID value="274"/> <!-- Weight -->
<AxisNameID value="256"/> <!-- Weight -->
<AxisOrdering value="0"/>
</Axis>
<Axis index="1">
<AxisTag value="cntr"/>
<AxisNameID value="275"/> <!-- Contrast -->
<AxisNameID value="257"/> <!-- Contrast -->
<AxisOrdering value="1"/>
</Axis>
</DesignAxisRecord>
<!-- AxisValueCount=0 -->
<ElidedFallbackNameID value="2"/> <!-- Regular -->
</STAT>
<cvar>

View File

@ -494,12 +494,6 @@
<namerecord nameID="273" platformID="1" platEncID="0" langID="0x0" unicode="True">
TestFamily-BlackHighContrast
</namerecord>
<namerecord nameID="274" platformID="1" platEncID="0" langID="0x0" unicode="True">
Weight
</namerecord>
<namerecord nameID="275" platformID="1" platEncID="0" langID="0x0" unicode="True">
Contrast
</namerecord>
<namerecord nameID="1" platformID="3" platEncID="1" langID="0x409">
Test Family
</namerecord>
@ -578,12 +572,6 @@
<namerecord nameID="273" platformID="3" platEncID="1" langID="0x409">
TestFamily-BlackHighContrast
</namerecord>
<namerecord nameID="274" platformID="3" platEncID="1" langID="0x409">
Weight
</namerecord>
<namerecord nameID="275" platformID="3" platEncID="1" langID="0x409">
Contrast
</namerecord>
</name>
<post>