Skip to content

Commit

Permalink
Remove some more remnants of VarComposites in ttGlyphSet
Browse files Browse the repository at this point in the history
Going to re-add for VARC table.
  • Loading branch information
behdad committed Dec 16, 2023
1 parent 3171e6d commit 98d30dc
Showing 1 changed file with 2 additions and 45 deletions.
47 changes: 2 additions & 45 deletions Lib/fontTools/ttLib/ttGlyphSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ def __init__(self, font, location, glyphsMapping, *, recalcBounds=True):
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)
Expand All @@ -50,34 +45,6 @@ def __init__(self, font, location, glyphsMapping, *, recalcBounds=True):
)
# 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

Expand Down Expand Up @@ -175,24 +142,14 @@ def draw(self, pen):
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:
Expand Down

0 comments on commit 98d30dc

Please sign in to comment.