[VARC] Adjust to latest flags change

This commit is contained in:
Behdad Esfahbod 2023-12-25 13:04:12 -07:00
parent 297e0bd257
commit b1142b60cb
4 changed files with 25 additions and 24 deletions

View File

@ -49,27 +49,28 @@ log = logging.getLogger(__name__)
class VarComponentFlags(IntFlag):
USE_MY_METRICS = 0x0001
RESET_UNSPECIFIED_AXES = 0x0002
RESET_UNSPECIFIED_AXES = 0x0001
GID_IS_24BIT = 0x0004
HAVE_AXES = 0x0002
HAVE_AXES = 0x0008
AXIS_VALUES_HAVE_VARIATION = 0x0004
TRANSFORM_HAS_VARIATION = 0x0008
AXIS_VALUES_HAVE_VARIATION = 0x0010
TRANSFORM_HAS_VARIATION = 0x0020
HAVE_TRANSLATE_X = 0x0010
HAVE_TRANSLATE_Y = 0x0020
HAVE_ROTATION = 0x0040
HAVE_TRANSLATE_X = 0x0040
HAVE_TRANSLATE_Y = 0x0080
HAVE_ROTATION = 0x0100
HAVE_SCALE_X = 0x0200
HAVE_SCALE_Y = 0x0400
HAVE_SKEW_X = 0x0800
HAVE_SKEW_Y = 0x1000
HAVE_TCENTER_X = 0x2000
HAVE_TCENTER_Y = 0x4000
USE_MY_METRICS = 0x0080
RESERVED = 0x8000
HAVE_SCALE_X = 0x0100
HAVE_SCALE_Y = 0x0200
HAVE_TCENTER_X = 0x0400
HAVE_TCENTER_Y = 0x0800
GID_IS_24BIT = 0x4000
HAVE_SKEW_X = 0x1000
HAVE_SKEW_Y = 0x2000
VarTransformMappingValues = namedtuple(
@ -160,8 +161,8 @@ class VarComponent:
def decompile(self, data, font, localState):
i = 0
self.flags = flags = _unpacker[2](data[i : i + 2])
i += 2
self.flags, i = _readVarInt32(data, i)
flags = self.flags
gidSize = 3 if flags & VarComponentFlags.GID_IS_24BIT else 2
glyphID = _unpacker[gidSize](data[i : i + gidSize])
@ -262,7 +263,7 @@ class VarComponent:
value = getattr(self.transform, attr_name)
data.append(write_transform_component(value, mapping_values))
return struct.pack(">H", flags) + bytesjoin(data)
return _writeVarInt32(flags) + bytesjoin(data)
def toXML(self, writer, ttFont, attrs):
attrs.append(("glyphName", self.glyphName))

Binary file not shown.

View File

@ -313,19 +313,19 @@
<VarComponent index="2" glyphName="glyph00006" flags="0"/>
</VarCompositeGlyph>
<VarCompositeGlyph index="2">
<VarComponent index="0" glyphName="glyph00008" flags="72" axisIndicesIndex="2" axisValues="(3537,)" translateX="-6.0"/>
<VarComponent index="0" glyphName="glyph00008" flags="18" axisIndicesIndex="2" axisValues="(3537,)" translateX="-6.0"/>
</VarCompositeGlyph>
<VarCompositeGlyph index="3">
<VarComponent index="0" glyphName="glyph00008" flags="88" axisIndicesIndex="0" axisValues="(-13184, 0, 7928)" axisValuesVarIndex="0" translateX="-3.0"/>
<VarComponent index="0" glyphName="glyph00008" flags="22" axisIndicesIndex="0" axisValues="(-13184, 0, 7928)" axisValuesVarIndex="0" translateX="-3.0"/>
</VarCompositeGlyph>
<VarCompositeGlyph index="4">
<VarComponent index="0" glyphName="glyph00009" flags="248" axisIndicesIndex="1" axisValues="(-8847, 655, -8484, 0, 0)" axisValuesVarIndex="1" transformVarIndex="2" translateX="-5.0" translateY="24.0"/>
<VarComponent index="0" glyphName="glyph00009" flags="62" axisIndicesIndex="1" axisValues="(-8847, 655, -8484, 0, 0)" axisValuesVarIndex="1" transformVarIndex="2" translateX="-5.0" translateY="24.0"/>
</VarCompositeGlyph>
<VarCompositeGlyph index="5">
<VarComponent index="0" glyphName="glyph00010" flags="248" axisIndicesIndex="0" axisValues="(-12714, -5843, 0)" axisValuesVarIndex="3" transformVarIndex="4" translateX="53.0" translateY="-231.0"/>
<VarComponent index="0" glyphName="glyph00010" flags="62" axisIndicesIndex="0" axisValues="(-12714, -5843, 0)" axisValuesVarIndex="3" transformVarIndex="4" translateX="53.0" translateY="-231.0"/>
</VarCompositeGlyph>
<VarCompositeGlyph index="6">
<VarComponent index="0" glyphName="glyph00009" flags="248" axisIndicesIndex="0" axisValues="(-4227, 819, -8484)" axisValuesVarIndex="5" transformVarIndex="6" translateX="-5.0" translateY="12.0"/>
<VarComponent index="0" glyphName="glyph00009" flags="62" axisIndicesIndex="0" axisValues="(-4227, 819, -8484)" axisValuesVarIndex="5" transformVarIndex="6" translateX="-5.0" translateY="12.0"/>
</VarCompositeGlyph>
</VarCompositeGlyphs>
</VARC>

Binary file not shown.