Remove some more remnants of VarComposites in ttGlyphSet

Going to re-add for VARC table.
This commit is contained in:
Behdad Esfahbod 2023-12-15 19:20:39 -07:00
parent bcd5e4c216
commit e9551c483a

View File

@ -30,11 +30,6 @@ class _TTGlyphSet(Mapping):
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.hMetrics = font["hmtx"].metrics
self.vMetrics = getattr(font.get("vmtx"), "metrics", None)
@ -49,34 +44,6 @@ class _TTGlyphSet(Mapping):
)
# 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):
return glyphName in self.glyphsMapping
@ -173,24 +140,14 @@ class _TTGlyphGlyf(_TTGlyph):
how that works.
"""
glyph, offset = self._getGlyphAndOffset()
with self.glyphSet.pushDepth() as depth:
if depth:
offset = 0 # Offset should only apply at top-level
glyph.draw(pen, self.glyphSet.glyfTable, offset)
glyph.draw(pen, self.glyphSet.glyfTable, offset)
def drawPoints(self, pen):
"""Draw the glyph onto ``pen``. See fontTools.pens.pointPen for details
how that works.
"""
glyph, offset = self._getGlyphAndOffset()
with self.glyphSet.pushDepth() as depth:
if depth:
offset = 0 # Offset should only apply at top-level
glyph.drawPoints(pen, self.glyphSet.glyfTable, offset)
glyph.drawPoints(pen, self.glyphSet.glyfTable, offset)
def _getGlyphAndOffset(self):
if self.glyphSet.location and self.glyphSet.gvarTable is not None: