Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
markAnchors = ['markAbove', 'markBelow', 'markAbove_1', 'markAbove_2',
'markBelow_1', 'markBelow_2', '_markAbove', '_markBelow',
'_markAbove_1', '_markAbove_2', '_markBelow_1', '_markBelow_2',
'_hamzaAbove', 'hamzaAbove', '_hamzaBelow', 'hamzaBelow'
# 'markAboveMark','markBelowMark','_markAboveMark','_markBelowMark'
]
if len(anchors):
for anchor in anchors:
if anchor.name in markAnchors:
anc = glyph.instantiateAnchor()
anc.x = anchor.x
anc.y = anchor.y
anc.name = anchor.name
glyph.appendAnchor(anc)
c = Contour()
c.addPoint((anchor.x, anchor.y), name=anchor.name, segmentType="move")
glyph.appendContour(c)
else:
continue
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)
self.root.findall('.axes')[0].append(axisElement)
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,
else:
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
for glyphName, group_ in stor.items():
if group_ == group:
del stor[glyphName]
def side1GroupForGlyphName(self, glyphName):
if not hasattr(self, "_side1Groups"):
self._bootstrapGroupsCache()
return self._side1Groups.get(glyphName)
def side2GroupForGlyphName(self, glyphName):
if not hasattr(self, "_side2Groups"):
self._bootstrapGroupsCache()
return self._side2Groups.get(glyphName)
class TContour(Contour):
def __init__(self, *args, **kwargs):
if "pointClass" not in kwargs:
kwargs["pointClass"] = TPoint
super().__init__(*args, **kwargs)
def _get_selected(self):
for point in self:
if not point.selected:
return False
return True
def _set_selected(self, value):
for point in self:
point.selected = value
self.postNotification(notification="Contour.SelectionChanged")
def createAnchors(self):
factor = self.getFactorOfUPM()
for g in self.UFO:
try:
sampleGlyph = self.templateUFO[g.name]
g.anchors = copy.deepcopy(sampleGlyph.anchors)
for point in g.anchors:
point.x *= factor
point.y *= factor
for point in sampleGlyph.anchors:
xVal = point.x * factor
yVal = point.y * factor
c = Contour()
c.addPoint((xVal, yVal), name=point.name, segmentType="move")
g.appendContour(c)
except:
pass