Revert "Remove some more remnants of VarComposites in ttGlyphSet"
This reverts commit 98d30dcf45e71b4352d9bfe2fee6ce4bfa198248.
This commit is contained in:
parent
e9551c483a
commit
a30ebf0a2f
@ -30,6 +30,11 @@ class _TTGlyphSet(Mapping):
|
|||||||
else {}
|
else {}
|
||||||
)
|
)
|
||||||
self.location = location if location is not None else {}
|
self.location = location if location is not None else {}
|
||||||
|
self.rawLocation = {} # VarComponent-only location
|
||||||
|
self.originalLocation = location if location is not None else {}
|
||||||
|
self.depth = 0
|
||||||
|
self.locationStack = []
|
||||||
|
self.rawLocationStack = []
|
||||||
self.glyphsMapping = glyphsMapping
|
self.glyphsMapping = glyphsMapping
|
||||||
self.hMetrics = font["hmtx"].metrics
|
self.hMetrics = font["hmtx"].metrics
|
||||||
self.vMetrics = getattr(font.get("vmtx"), "metrics", None)
|
self.vMetrics = getattr(font.get("vmtx"), "metrics", None)
|
||||||
@ -44,6 +49,34 @@ class _TTGlyphSet(Mapping):
|
|||||||
)
|
)
|
||||||
# TODO VVAR, VORG
|
# TODO VVAR, VORG
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def pushLocation(self, location, reset: bool):
|
||||||
|
self.locationStack.append(self.location)
|
||||||
|
self.rawLocationStack.append(self.rawLocation)
|
||||||
|
if reset:
|
||||||
|
self.location = self.originalLocation.copy()
|
||||||
|
self.rawLocation = self.defaultLocationNormalized.copy()
|
||||||
|
else:
|
||||||
|
self.location = self.location.copy()
|
||||||
|
self.rawLocation = {}
|
||||||
|
self.location.update(location)
|
||||||
|
self.rawLocation.update(location)
|
||||||
|
|
||||||
|
try:
|
||||||
|
yield None
|
||||||
|
finally:
|
||||||
|
self.location = self.locationStack.pop()
|
||||||
|
self.rawLocation = self.rawLocationStack.pop()
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def pushDepth(self):
|
||||||
|
try:
|
||||||
|
depth = self.depth
|
||||||
|
self.depth += 1
|
||||||
|
yield depth
|
||||||
|
finally:
|
||||||
|
self.depth -= 1
|
||||||
|
|
||||||
def __contains__(self, glyphName):
|
def __contains__(self, glyphName):
|
||||||
return glyphName in self.glyphsMapping
|
return glyphName in self.glyphsMapping
|
||||||
|
|
||||||
@ -140,14 +173,24 @@ class _TTGlyphGlyf(_TTGlyph):
|
|||||||
how that works.
|
how that works.
|
||||||
"""
|
"""
|
||||||
glyph, offset = self._getGlyphAndOffset()
|
glyph, offset = self._getGlyphAndOffset()
|
||||||
glyph.draw(pen, self.glyphSet.glyfTable, offset)
|
|
||||||
|
with self.glyphSet.pushDepth() as depth:
|
||||||
|
if depth:
|
||||||
|
offset = 0 # Offset should only apply at top-level
|
||||||
|
|
||||||
|
glyph.draw(pen, self.glyphSet.glyfTable, offset)
|
||||||
|
|
||||||
def drawPoints(self, pen):
|
def drawPoints(self, pen):
|
||||||
"""Draw the glyph onto ``pen``. See fontTools.pens.pointPen for details
|
"""Draw the glyph onto ``pen``. See fontTools.pens.pointPen for details
|
||||||
how that works.
|
how that works.
|
||||||
"""
|
"""
|
||||||
glyph, offset = self._getGlyphAndOffset()
|
glyph, offset = self._getGlyphAndOffset()
|
||||||
glyph.drawPoints(pen, self.glyphSet.glyfTable, offset)
|
|
||||||
|
with self.glyphSet.pushDepth() as depth:
|
||||||
|
if depth:
|
||||||
|
offset = 0 # Offset should only apply at top-level
|
||||||
|
|
||||||
|
glyph.drawPoints(pen, self.glyphSet.glyfTable, offset)
|
||||||
|
|
||||||
def _getGlyphAndOffset(self):
|
def _getGlyphAndOffset(self):
|
||||||
if self.glyphSet.location and self.glyphSet.gvarTable is not None:
|
if self.glyphSet.location and self.glyphSet.gvarTable is not None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user