def _load_contour(glyph, segments): contour = Contour() contour._glyph = glyph contour._points = [] for s in segments: if s[-1] == "x": # sx? s = s[:-3] if s[-1] == "s": smooth = True s = s[:-2] else: smooth = False if s[-1] == "c": # Close s = s[:-2] points = s.split(" ") for ix, position in enumerate(points): p = Point() p._contour = contour p.x, p.y = [float(pos) for pos in position.split(" ")] if len(points) == 1: p.type = "line" elif ix == 2: p.type = "curve" else: p.type = "offcurve" if ix == len(points) - 1 and smooth: p.smooth = True else: p.smooth = False contour._points.append(p) if len(contour._points) and contour._points[-1].type == "offcurve": contour._points[0].type = "curve" contour._correct_direction() return contour
def _load_gspath(gspath, glyph): contour = Contour() contour._glyph = glyph contour._points = [_load_gspoint(p, contour) for p in gspath.nodes] contour._clockwise = gspath.direction == 1 return contour
def _load_dccontour(dccontour, glyph): contour = Contour() contour._glyph = glyph contour._points = [_load_dcpoint(p, contour) for p in dccontour] contour.clockwise = dccontour.clockwise return contour