コード例 #1
0
ファイル: test_layer.py プロジェクト: anthrotype/defcon
 def test_glyph_dispatcher_inserted(self):
     font = Font()
     font.newGlyph("A")
     glyph = font["A"]
     pen = glyph.getPointPen()
     pen.beginPath()
     pen.addPoint((0, 0), segmentType="line")
     pen.addPoint((0, 100), segmentType="line")
     pen.addPoint((100, 100), segmentType="line")
     pen.addPoint((100, 0), segmentType="line")
     pen.endPath()
     contour = glyph[0]
     component = Component()
     glyph.appendComponent(component)
     anchor = Anchor()
     glyph.appendAnchor(anchor)
     guideline = Guideline()
     glyph.appendGuideline(guideline)
     sourceGlyph = glyph
     newFont = Font()
     insertedGlyph = newFont.insertGlyph(sourceGlyph)
     contour = insertedGlyph[0]
     self.assertTrue(contour.getParent(), insertedGlyph)
     self.assertTrue(contour.dispatcher, newFont.dispatcher)
     component = insertedGlyph.components[0]
     self.assertTrue(component.getParent(), insertedGlyph)
     self.assertTrue(component.dispatcher, newFont.dispatcher)
     anchor = insertedGlyph.anchors[0]
     self.assertTrue(anchor.getParent(), insertedGlyph)
     self.assertTrue(anchor.dispatcher, newFont.dispatcher)
     guideline = insertedGlyph.guidelines[0]
     self.assertTrue(guideline.getParent(), insertedGlyph)
     self.assertTrue(guideline.dispatcher, newFont.dispatcher)
コード例 #2
0
ファイル: test_layer.py プロジェクト: anthrotype/defcon
 def test_glyph_dispatcher_new(self):
     font = Font()
     font.newGlyph("A")
     glyph = font["A"]
     pen = glyph.getPointPen()
     pen.beginPath()
     pen.addPoint((0, 0), segmentType="line")
     pen.addPoint((0, 100), segmentType="line")
     pen.addPoint((100, 100), segmentType="line")
     pen.addPoint((100, 0), segmentType="line")
     pen.endPath()
     contour = glyph[0]
     self.assertEqual(contour.getParent(), glyph)
     self.assertEqual(contour.dispatcher, font.dispatcher)
     component = Component()
     glyph.appendComponent(component)
     self.assertEqual(component.getParent(), glyph)
     self.assertEqual(component.dispatcher, font.dispatcher)
     anchor = Anchor()
     glyph.appendAnchor(anchor)
     self.assertEqual(anchor.getParent(), glyph)
     self.assertEqual(anchor.dispatcher, font.dispatcher)
     guideline = Guideline()
     glyph.appendGuideline(guideline)
     self.assertEqual(guideline.getParent(), glyph)
     self.assertEqual(guideline.dispatcher, font.dispatcher)
コード例 #3
0
 def test_glyph_dispatcher_inserted(self):
     font = Font()
     font.newGlyph("A")
     glyph = font["A"]
     pen = glyph.getPointPen()
     pen.beginPath()
     pen.addPoint((0, 0), segmentType="line")
     pen.addPoint((0, 100), segmentType="line")
     pen.addPoint((100, 100), segmentType="line")
     pen.addPoint((100, 0), segmentType="line")
     pen.endPath()
     contour = glyph[0]
     component = Component()
     glyph.appendComponent(component)
     anchor = Anchor()
     glyph.appendAnchor(anchor)
     guideline = Guideline()
     glyph.appendGuideline(guideline)
     sourceGlyph = glyph
     newFont = Font()
     insertedGlyph = newFont.insertGlyph(sourceGlyph)
     contour = insertedGlyph[0]
     self.assertTrue(contour.getParent(), insertedGlyph)
     self.assertTrue(contour.dispatcher, newFont.dispatcher)
     component = insertedGlyph.components[0]
     self.assertTrue(component.getParent(), insertedGlyph)
     self.assertTrue(component.dispatcher, newFont.dispatcher)
     anchor = insertedGlyph.anchors[0]
     self.assertTrue(anchor.getParent(), insertedGlyph)
     self.assertTrue(anchor.dispatcher, newFont.dispatcher)
     guideline = insertedGlyph.guidelines[0]
     self.assertTrue(guideline.getParent(), insertedGlyph)
     self.assertTrue(guideline.dispatcher, newFont.dispatcher)
コード例 #4
0
 def test_glyph_dispatcher_new(self):
     font = Font()
     font.newGlyph("A")
     glyph = font["A"]
     pen = glyph.getPointPen()
     pen.beginPath()
     pen.addPoint((0, 0), segmentType="line")
     pen.addPoint((0, 100), segmentType="line")
     pen.addPoint((100, 100), segmentType="line")
     pen.addPoint((100, 0), segmentType="line")
     pen.endPath()
     contour = glyph[0]
     self.assertEqual(contour.getParent(), glyph)
     self.assertEqual(contour.dispatcher, font.dispatcher)
     component = Component()
     glyph.appendComponent(component)
     self.assertEqual(component.getParent(), glyph)
     self.assertEqual(component.dispatcher, font.dispatcher)
     anchor = Anchor()
     glyph.appendAnchor(anchor)
     self.assertEqual(anchor.getParent(), glyph)
     self.assertEqual(anchor.dispatcher, font.dispatcher)
     guideline = Guideline()
     glyph.appendGuideline(guideline)
     self.assertEqual(guideline.getParent(), glyph)
     self.assertEqual(guideline.dispatcher, font.dispatcher)
コード例 #5
0
 def test_appendGuideline(self):
     glyph = Glyph()
     glyph.dirty = False
     guideline = Guideline()
     glyph.appendGuideline(guideline)
     self.assertEqual(len(glyph.guidelines), 1)
     self.assertTrue(glyph.dirty)
     self.assertEqual(guideline.getParent(), glyph)
コード例 #6
0
ファイル: test_glyph.py プロジェクト: anthrotype/defcon
 def test_appendGuideline(self):
     glyph = Glyph()
     glyph.dirty = False
     guideline = Guideline()
     glyph.appendGuideline(guideline)
     self.assertEqual(len(glyph.guidelines), 1)
     self.assertTrue(glyph.dirty)
     self.assertEqual(guideline.getParent(), glyph)