Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getGlyph(self):
glyph = Glyph()
pointPen = glyph.getPointPen()
self.drawPoints(pointPen)
return glyph
from fontParts.base import BaseGlyph
from fontParts.base.errors import FontPartsError
from fontParts.fontshell.base import RBaseObject
from fontParts.fontshell.contour import RContour
from fontParts.fontshell.component import RComponent
from fontParts.fontshell.anchor import RAnchor
from fontParts.fontshell.guideline import RGuideline
from fontParts.fontshell.image import RImage
from fontParts.fontshell.lib import RLib
from fontTools.ufoLib.glifLib import (GlifLibError, readGlyphFromString,
writeGlyphToString)
class RGlyph(RBaseObject, BaseGlyph):
wrapClass = defcon.Glyph
contourClass = RContour
componentClass = RComponent
anchorClass = RAnchor
guidelineClass = RGuideline
imageClass = RImage
libClass = RLib
# --------------
# Identification
# --------------
# Name
def _get_name(self):
return self.naked().name
def test_extract_scaled_glyph_as_Defcon_Glyph(self):
"""Test scaled glyph retrieval as a Defcon glyph."""
from defcon import Glyph
for testFont in [self.smallFont, self.stemedSmallFont]:
scaledGlyph = Glyph()
for glyphName in self.glyphNames:
testFont.extractGlyph(glyphName, scaledGlyph)
self.assertIsInstance(scaledGlyph, Glyph)
self.assertEqual(scaledGlyph.name, glyphName)
if transformation == _defaultTransformation:
baseGlyph.drawPoints(self)
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
braceLayerNamePattern = u"#brace "
braceLocationLibKey = "designspace.location"
def getGlyph(self):
glyph = Glyph()
pointPen = glyph.getPointPen()
self.drawPoints(pointPen)
return glyph
def find_shape_diffs(self):
"""Report differences in glyph shapes, using BooleanOperations."""
self.build_names()
area_pen = GlyphAreaPen(None)
pen = PointToSegmentPen(area_pen)
mismatched = {}
for name in self.names:
glyph_a = Glyph()
glyph_b = Glyph()
self.glyph_set_a[name].draw(
Qu2CuPen(glyph_a.getPen(), self.glyph_set_a))
self.glyph_set_b[name].draw(
Qu2CuPen(glyph_b.getPen(), self.glyph_set_b))
booleanOperations.xor(list(glyph_a), list(glyph_b), pen)
area = abs(area_pen.pop())
if area:
mismatched[name] = (area)
stats = self.stats['compared']
for name, area in mismatched.items():
stats.append((area, name, self.basepath))
self.optimizeCurve = optimizeCurve
self.connectionCallback = getattr(self, "connection%s" % (connection.title()))
self.capCallback = getattr(self, "cap%s" % (cap.title()))
self.originalGlyph = Glyph()
self.originalPen = self.originalGlyph.getPen()
self.outerGlyph = Glyph()
self.outerPen = self.outerGlyph.getPen()
self.outerCurrentPoint = None
self.outerFirstPoint = None
self.outerPrevPoint = None
self.innerGlyph = Glyph()
self.innerPen = self.innerGlyph.getPen()
self.innerCurrentPoint = None
self.innerFirstPoint = None
self.innerPrevPoint = None
self.prevPoint = None
self.firstPoint = None
self.firstAngle = None
self.prevAngle = None
self.shouldHandleMove = True
self.components = []
self.drawSettings()
def setUp(self):
testGlyph = Glyph()
pen = testGlyph.getPen()
self.drawTestGlyph(pen)
self.testGlyph = testGlyph
if transformation == _defaultTransformation:
baseGlyph.drawPoints(self)
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)
def getGlyph(self):
glyph = Glyph()
pointPen = glyph.getPointPen()
self.drawPoints(pointPen)
return glyph