[visitor_test] Implement glyf table visiting
This commit is contained in:
parent
a0686e8d2e
commit
be7df107e2
@ -105,10 +105,10 @@ class TTVisitor(Visitor):
|
||||
|
||||
@TTVisitor.register(TTFont)
|
||||
def visit(visitor, font):
|
||||
if hasattr(font, "visited"):
|
||||
if hasattr(visitor, "font"):
|
||||
return False
|
||||
font.visited = True
|
||||
visitor.font = font
|
||||
for tag in font.keys():
|
||||
visitor.visit(font[tag])
|
||||
del font.visited
|
||||
del visitor.font
|
||||
return False
|
||||
|
@ -61,6 +61,25 @@ def visit(visitor, obj, attr, metrics):
|
||||
metrics[g] = visitor.scale(advance), visitor.scale(lsb)
|
||||
|
||||
|
||||
@ScalerVisitor.register_attr(ttLib.getTableClass("glyf"), "glyphs")
|
||||
def visit(visitor, obj, attr, glyphs):
|
||||
for g in glyphs.values():
|
||||
if g.isComposite():
|
||||
for component in g.components:
|
||||
component.x = visitor.scale(component.x)
|
||||
component.y = visitor.scale(component.y)
|
||||
else:
|
||||
for attr in ("xMin", "xMax", "yMin", "yMax"):
|
||||
v = getattr(g, attr, None)
|
||||
if v is not None:
|
||||
setattr(g, attr, visitor.scale(v))
|
||||
|
||||
glyf = visitor.font["glyf"]
|
||||
coordinates = g.getCoordinates(glyf)[0]
|
||||
for i, (x, y) in enumerate(coordinates):
|
||||
coordinates[i] = visitor.scale(x), visitor.scale(y)
|
||||
|
||||
|
||||
# GPOS
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user