[cff] Store varStore in CharStrings
This commit is contained in:
parent
a7cda37fbb
commit
4650b8d293
@ -1125,8 +1125,9 @@ class CharStrings(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, file, charset, globalSubrs, private, fdSelect, fdArray,
|
def __init__(self, file, charset, globalSubrs, private, fdSelect, fdArray,
|
||||||
isCFF2=None):
|
isCFF2=None, varStore=None):
|
||||||
self.globalSubrs = globalSubrs
|
self.globalSubrs = globalSubrs
|
||||||
|
self.varStore = varStore
|
||||||
if file is not None:
|
if file is not None:
|
||||||
self.charStringsIndex = SubrsIndex(
|
self.charStringsIndex = SubrsIndex(
|
||||||
file, globalSubrs, private, fdSelect, fdArray, isCFF2=isCFF2)
|
file, globalSubrs, private, fdSelect, fdArray, isCFF2=isCFF2)
|
||||||
@ -1516,6 +1517,7 @@ class CharStringsConverter(TableConverter):
|
|||||||
file = parent.file
|
file = parent.file
|
||||||
isCFF2 = parent._isCFF2
|
isCFF2 = parent._isCFF2
|
||||||
charset = parent.charset
|
charset = parent.charset
|
||||||
|
varStore = getattr(parent, "VarStore", None)
|
||||||
globalSubrs = parent.GlobalSubrs
|
globalSubrs = parent.GlobalSubrs
|
||||||
if hasattr(parent, "FDArray"):
|
if hasattr(parent, "FDArray"):
|
||||||
fdArray = parent.FDArray
|
fdArray = parent.FDArray
|
||||||
@ -1529,7 +1531,7 @@ class CharStringsConverter(TableConverter):
|
|||||||
private = parent.Private
|
private = parent.Private
|
||||||
file.seek(value) # Offset(0)
|
file.seek(value) # Offset(0)
|
||||||
charStrings = CharStrings(
|
charStrings = CharStrings(
|
||||||
file, charset, globalSubrs, private, fdSelect, fdArray, isCFF2=isCFF2)
|
file, charset, globalSubrs, private, fdSelect, fdArray, isCFF2=isCFF2, varStore=varStore)
|
||||||
return charStrings
|
return charStrings
|
||||||
|
|
||||||
def write(self, parent, value):
|
def write(self, parent, value):
|
||||||
@ -1551,7 +1553,7 @@ class CharStringsConverter(TableConverter):
|
|||||||
# there is no fdArray.
|
# there is no fdArray.
|
||||||
private, fdSelect, fdArray = parent.Private, None, None
|
private, fdSelect, fdArray = parent.Private, None, None
|
||||||
charStrings = CharStrings(
|
charStrings = CharStrings(
|
||||||
None, None, parent.GlobalSubrs, private, fdSelect, fdArray)
|
None, None, parent.GlobalSubrs, private, fdSelect, fdArray, varStore=getattr(parent, "VarStore", None))
|
||||||
charStrings.fromXML(name, attrs, content)
|
charStrings.fromXML(name, attrs, content)
|
||||||
return charStrings
|
return charStrings
|
||||||
|
|
||||||
|
@ -187,6 +187,7 @@ class _TTVarGlyph(_TTGlyph):
|
|||||||
super().__init__(glyphs, glyphs[glyphName])
|
super().__init__(glyphs, glyphs[glyphName])
|
||||||
|
|
||||||
self._ttFont = ttFont
|
self._ttFont = ttFont
|
||||||
|
self._glyphs = glyphs
|
||||||
self._glyphName = glyphName
|
self._glyphName = glyphName
|
||||||
self._location = location
|
self._location = location
|
||||||
|
|
||||||
@ -194,15 +195,12 @@ class _TTVarGlyph(_TTGlyph):
|
|||||||
class _TTVarGlyphCFF(_TTVarGlyph):
|
class _TTVarGlyphCFF(_TTVarGlyph):
|
||||||
|
|
||||||
def draw(self, pen):
|
def draw(self, pen):
|
||||||
from fontTools.varLib.varStore import VarStoreInstancer
|
varStore = self._glyphs.varStore
|
||||||
table_tag = "CFF2" if "CFF2" in self._ttFont else "CFF "
|
|
||||||
cff = self._ttFont[table_tag].cff
|
|
||||||
topDict = cff.topDictIndex[0]
|
|
||||||
varStore = getattr(topDict, "VarStore", None)
|
|
||||||
if varStore is None:
|
if varStore is None:
|
||||||
blender = None
|
blender = None
|
||||||
else:
|
else:
|
||||||
vsInstancer = VarStoreInstancer(topDict.VarStore.otVarStore, self._ttFont['fvar'].axes, self._location)
|
from fontTools.varLib.varStore import VarStoreInstancer
|
||||||
|
vsInstancer = VarStoreInstancer(varStore.otVarStore, self._ttFont['fvar'].axes, self._location)
|
||||||
blender = vsInstancer.interpolateFromDeltas
|
blender = vsInstancer.interpolateFromDeltas
|
||||||
self._glyph.draw(pen, blender)
|
self._glyph.draw(pen, blender)
|
||||||
self.width = self._ttFont['hmtx'][self._glyphName][0]
|
self.width = self._ttFont['hmtx'][self._glyphName][0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user