Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def registerAllFactories():
for name, (factory, destructiveNotifications) in _glyphFactories.items():
registerRepresentationFactory(
Glyph, name, factory, destructiveNotifications=destructiveNotifications
)
for name, (factory, destructiveNotifications) in _componentFactories.items():
registerRepresentationFactory(
Component, name, factory, destructiveNotifications=destructiveNotifications
)
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,
logPath=None,
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 = {}
self._infoMutator = None
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"
def __init__(self, readerClass=None, writerClass=None, fontClass=None, ufoVersion=3):
import defcon
from fontParts.base import BaseComponent
from fontParts.fontshell.base import RBaseObject
class RComponent(RBaseObject, BaseComponent):
wrapClass = defcon.Component
# ----------
# Attributes
# ----------
# baseGlyph
def _get_baseGlyph(self):
return self.naked().baseGlyph
def _set_baseGlyph(self, value):
self.naked().baseGlyph = value
# transformation
def _get_transformation(self):
def contextMenuEvent(self, event):
widget = self.parent()
self._cachedPos = event.globalPos()
menu = QMenu(widget)
item = widget.itemAt(event.localPos())
targetContour = None
if item is not None:
if isinstance(item, tuple):
contour, index = item
targetContour = contour
if True or contour[index].segmentType is not None: # XXX
menu.addAction(
self.tr("Set Start Point"),
lambda: self._setStartPoint(contour, index),
)
elif isinstance(item, Component):
menu.addAction(
self.tr("Go To Glyph"), lambda: self._goToGlyph(item.baseGlyph)
)
menu.addAction(
self.tr("Decompose"), lambda: self._glyph.decomposeComponent(item)
)
menu.addAction(
self.tr("Decompose All"), self._glyph.decomposeAllComponents
)
elif isinstance(item, Guideline):
if isinstance(item.getParent(), Glyph):
text = self.tr("Make Global")
else:
text = self.tr("Make Local")
menu.addAction(text, lambda: self._toggleGuideline(item))
if len(self._glyph):
dx, dy = center
x, y = pt
sT = Identity.translate(dx, dy)
sT = sT.scale(x, y)
sT = sT.translate(-dx, -dy)
self.transform(sT)
def transform(self, matrix):
self.x, self.y = matrix.transformPoint((self.x, self.y))
def snap(self, base):
self.x = _snap(self.x, base)
self.y = _snap(self.y, base)
class TComponent(Component):
def __init__(self, *args, **kwargs):
self._selected = False
super().__init__(*args, **kwargs)
def _get_selected(self):
return self._selected
def _set_selected(self, value):
if value == self._selected:
return
self._selected = value
self.postNotification(notification="Component.SelectionChanged")
selected = property(
_get_selected,
_set_selected,
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 = {}
self._infoMutator = None