Add interpolation of cvt/cvar table

This commit is contained in:
Jens Kutilek 2017-10-05 13:32:06 +02:00
parent 72927cde87
commit 80414303d0
2 changed files with 37 additions and 0 deletions

View File

@ -152,6 +152,21 @@ def main(args=None):
coordinates += GlyphCoordinates(delta) * scalar
_SetCoordinates(varfont, glyphname, coordinates)
# Interpolate cvt
if 'cvar' in varfont:
cvar = varfont['cvar']
cvt = varfont['cvt ']
deltas = {}
for var in cvar.variations:
scalar = supportScalar(loc, var.axes)
if not scalar: continue
for i, c in enumerate(var.coordinates):
if c is not None:
deltas[i] = deltas.get(i, 0) + scalar * c
for i, delta in deltas.items():
cvt[i] += int(round(delta))
print("Removing variable tables")
for tag in ('avar','cvar','fvar','gvar','HVAR','MVAR','VVAR','STAT'):
if tag in varfont:

View File

@ -128,6 +128,11 @@
</cmap_format_4>
</cmap>
<cvt>
<cv index="0" value="474"/>
<cv index="1" value="677"/>
</cvt>
<loca>
<!-- The 'loca' table will be calculated by the compiler -->
</loca>
@ -848,6 +853,23 @@
</ValueRecord>
</MVAR>
<cvar>
<version major="1" minor="0"/>
<tuple>
<coord axis="wght" value="-1.0"/>
<delta cvt="0" value="-4"/>
</tuple>
<tuple>
<coord axis="wght" value="1.0"/>
<delta cvt="0" value="13"/>
</tuple>
<tuple>
<coord axis="wght" value="1.0"/>
<coord axis="cntr" value="1.0"/>
<delta cvt="0" value="13"/>
</tuple>
</cvar>
<fvar>
<!-- Weight -->