-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
I noticed that an interpolation with scaleFast may mangle curves if the starting point is inconsistent across masters – one contour may start with an offcurve, the other with an oncurve. While this doesn’t cause any problems in many interpolation scenarios, scaleFast isn’t that forgiving:
I solved the issue by pre-processing my UFOs with this little script first, which makes sure all contours start with oncurve points:
from fontTools.ufoLib.pointPen import PointToSegmentPen
def redraw_glyph(g):
contours = []
for contour in g.contours:
points = [p for p in contour.points]
while points[0].type == 'offcurve':
points.append(points.pop(0))
contours.append(points)
g.prepareUndo('redraw')
rg = RGlyph()
ppen = PointToSegmentPen(rg.getPen())
for contour in contours:
ppen.beginPath()
for point in contour:
if point.type == 'offcurve':
ptype = None
else:
ptype = point.type
ppen.addPoint((point.x, point.y), ptype)
ppen.endPath()
g.clearContours()
g.appendGlyph(rg)
g.performUndo()
f = CurrentFont()
glyphs_with_contours = [g for g in f if len(g.contours)]
glyphs_with_offcurve_start = []
for g in glyphs_with_contours:
for contour in g.contours:
first_point = contour.points[0]
first_bPoint = contour.bPoints[0]
first_point_coords = (first_point.x, first_point.y)
if first_point_coords != first_bPoint.anchor:
glyphs_with_offcurve_start.append(g)
for g in glyphs_with_offcurve_start:
print(g.name)
redraw_glyph(g)
(for a modernized version of this script, which processes all UFOs at once, see https://gist.github.com/frankrolf/e75980e3895df26615cc8ed1e60f9c5b )
Metadata
Metadata
Assignees
Labels
No labels
