Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def add_point(self, x, y):
"""Add a Point to the currently active contour"""
# print "Yahoo"
point = Point((globals.invX(x), globals.invY(y)))
# print "{" + str(point.x) + "," + str(point.y) + "}"
# point.x = globals.invX(x)
# point.y = globals.invY(y)
if len(self.contour[:]) == 0:
# add the point to the contour
point.segmentType = u'move'
point.smooth = False
self.contour.appendPoint(point)
elif self._check_close_contour(point):
# convert the first point to a line type
# print "the contour should be closed now"
# close the contour
def draw(glyph, ufo_glyph, smooth=True):
for path in glyph.vectorize(smooth):
contour = defcon.Contour()
for p in path:
contour.appendPoint(defcon.Point(p, 'line'))
ufo_glyph.appendContour(contour)
class DesignSpaceDocumentReader(object):
""" Read a designspace description.
Build Instance objects, generate them.
* documentPath: path of the document to read
* ufoVersion: target UFO version
* roundGeometry: apply rounding to all geometry
"""
_fontClass = defcon.Font
_glyphClass = defcon.Glyph
_libClass = defcon.Lib
_glyphContourClass = defcon.Contour
_glyphPointClass = defcon.Point
_glyphComponentClass = defcon.Component
_glyphAnchorClass = defcon.Anchor
_kerningClass = defcon.Kerning
_groupsClass = defcon.Groups
_infoClass = defcon.Info
_featuresClass = defcon.Features
_instanceWriterClass = InstanceWriter
_tempFontLibGlyphMuteKey = "_mutatorMath.temp.mutedGlyphNames"
_tempFontLocationKey = "_mutatorMath.temp.fontLocation"
def __init__(self, documentPath,
ufoVersion,
roundGeometry=False,
verbose=False,
transformPointPen = TransformPointPen(self, transformation)
baseGlyph.drawPoints(transformPointPen)
class DesignSpaceProcessor(DesignSpaceDocument):
"""
builder of glyphs from designspaces
validate the data
if it works, make a generating thing
"""
fontClass = defcon.Font
glyphClass = defcon.Glyph
libClass = defcon.Lib
glyphContourClass = defcon.Contour
glyphPointClass = defcon.Point
glyphComponentClass = defcon.Component
glyphAnchorClass = defcon.Anchor
kerningClass = defcon.Kerning
groupsClass = defcon.Groups
infoClass = defcon.Info
featuresClass = defcon.Features
mathInfoClass = MathInfo
mathGlyphClass = MathGlyph
mathKerningClass = MathKerning
def __init__(self, readerClass=None, writerClass=None, fontClass=None, ufoVersion=3):
super(DesignSpaceProcessor, self).__init__(readerClass=readerClass, writerClass=writerClass, fontClass=fontClass)
self.ufoVersion = ufoVersion # target UFO version
self.roundGeometry = False
self._glyphMutators = {}
transformPointPen = TransformPointPen(self, transformation)
baseGlyph.drawPoints(transformPointPen)
class DesignSpaceProcessor(DesignSpaceDocument):
"""
builder of glyphs from designspaces
validate the data
if it works, make a generating thing
"""
fontClass = defcon.Font
glyphClass = defcon.Glyph
libClass = defcon.Lib
glyphContourClass = defcon.Contour
glyphPointClass = defcon.Point
glyphComponentClass = defcon.Component
glyphAnchorClass = defcon.Anchor
kerningClass = defcon.Kerning
groupsClass = defcon.Groups
infoClass = defcon.Info
featuresClass = defcon.Features
mathInfoClass = MathInfo
mathGlyphClass = MathGlyph
mathKerningClass = MathKerning
braceLayerNamePattern = u"#brace "
braceLocationLibKey = "designspace.location"
braceGlyphSourceKey = "designspace.glyph.source"
sT = sT.scale(x, y)
sT = sT.translate(-dx, -dy)
self.transform(sT)
def transform(self, matrix):
self.transformation = tuple(matrix.transform(self.transformation))
def snap(self, base):
xScale, xyScale, yxScale, yScale, xOffset, yOffset = self._transformation
xOffset = _snap(xOffset, base)
yOffset = _snap(yOffset, base)
# TODO: should scale be snapped too?
self.transformation = (xScale, xyScale, yxScale, yScale, xOffset, yOffset)
class TPoint(Point):
__slots__ = ["_selected"]
def __init__(self, pt, selected=False, **kwargs):
super().__init__(pt, **kwargs)
self._selected = selected
def _get_selected(self):
return self._selected
def _set_selected(self, value):
self._selected = value
selected = property(
_get_selected,
_set_selected,
doc="A boolean indicating the selected state of the point.",
transformPointPen = TransformPointPen(self, transformation)
baseGlyph.drawPoints(transformPointPen)
class DesignSpaceProcessor(DesignSpaceDocument):
"""
builder of glyphs from designspaces
validate the data
if it works, make a generating thing
"""
fontClass = defcon.Font
glyphClass = defcon.Glyph
libClass = defcon.Lib
glyphContourClass = defcon.Contour
glyphPointClass = defcon.Point
glyphComponentClass = defcon.Component
glyphAnchorClass = defcon.Anchor
kerningClass = defcon.Kerning
groupsClass = defcon.Groups
infoClass = defcon.Info
featuresClass = defcon.Features
mathInfoClass = MathInfo
mathGlyphClass = MathGlyph
mathKerningClass = MathKerning
def __init__(self, readerClass=None, writerClass=None, fontClass=None, ufoVersion=3):
super(DesignSpaceProcessor, self).__init__(readerClass=readerClass, writerClass=writerClass, fontClass=fontClass)
self.ufoVersion = ufoVersion # target UFO version
self.roundGeometry = False
self._glyphMutators = {}