/usr/lib/python3/dist-packages/defcon/pens/glyphObjectPointPen.py is in python3-defcon 0.3.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | from ufoLib.pointPen import AbstractPointPen
class GlyphObjectPointPen(AbstractPointPen):
def __init__(self, glyph):
self._glyph = glyph
self._contour = None
self.skipConflictingIdentifiers = False
def beginPath(self, identifier=None, **kwargs):
self._contour = self._glyph.instantiateContour()
self._contour.disableNotifications()
if identifier is not None:
if self.skipConflictingIdentifiers and identifier in self._glyph.identifiers:
pass
else:
self._contour.identifier = identifier
def endPath(self):
self._contour.dirty = False
self._glyph.appendContour(self._contour)
self._contour.enableNotifications()
self._contour = None
def addPoint(self, pt, segmentType=None, smooth=False, name=None, identifier=None, **kwargs):
if self.skipConflictingIdentifiers and identifier in self._glyph.identifiers:
identifier = None
self._contour.addPoint(pt, segmentType, smooth, name, identifier=identifier)
def addComponent(self, baseGlyphName, transformation, identifier=None, **kwargs):
if self.skipConflictingIdentifiers and identifier in self._glyph.identifiers:
identifier = None
component = self._glyph.instantiateComponent()
component.baseGlyph = baseGlyphName
component.transformation = transformation
component.identifier = identifier
self._glyph.appendComponent(component)
class GlyphObjectLoadingPointPen(GlyphObjectPointPen):
def __init__(self, glyph):
super(GlyphObjectLoadingPointPen, self).__init__(glyph)
self._contours = glyph._shallowLoadedContours
def beginPath(self, identifier=None, **kwargs):
contour = dict(points=[])
if identifier is not None and self.skipConflictingIdentifiers and identifier in self._glyph.identifiers:
identifier = None
if identifier is not None:
if identifier in self._glyph.identifiers:
raise DefconError("The contour identifier (%s) is already used." % identifier)
# FIXME: we should do self._glyph.identifiers.add(identifier)
# otherwise the shallow contours could define the same identifier multiple times
# or even between shallow loading and real loading something else could
# take the identifier. The check above is pretty much worthless
# without storing the identifier.
contour["identifier"] = identifier
self._contours.append(contour)
def endPath(self):
pass
def addPoint(self, pt, segmentType=None, smooth=False, name=None, identifier=None, **kwargs):
args = (pt,)
kwargs = dict(
segmentType=segmentType,
smooth=smooth,
name=name
)
if identifier is not None and self.skipConflictingIdentifiers and identifier in self._glyph.identifiers:
identifier = None
if identifier is not None:
if identifier in self._glyph.identifiers:
raise DefconError("The contour identifier (%s) is already used." % identifier)
# FIXME: we should do self._glyph.identifiers.add(identifier)
# otherwise the shallow contours could define the same identifier multiple times
# or even between shallow loading and real loading something else could
# take the identifier. The check above is pretty much worthless
# without storing the identifier.
kwargs["identifier"] = identifier
self._contours[-1]["points"].append((args, kwargs))
|