Skip to content

Commit

Permalink
Merge pull request #272 from robotools/areaPenWithGlyphSet
Browse files Browse the repository at this point in the history
add glyphset so glyphs with components are also getting an proper area value
  • Loading branch information
typemytype committed Jan 15, 2020
2 parents 72b6550 + d4bdca3 commit 71f1cd9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
19 changes: 19 additions & 0 deletions Lib/defcon/test/objects/test_glyph.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,25 @@ def test_pointInside(self):
self.assertFalse(glyph.pointInside((350, 350)))
self.assertFalse(glyph.pointInside((-100, -100)))

def test_area(self):
font = Font()

baseGlyph = font.newGlyph("baseGlyph")
pointPen = baseGlyph.getPointPen()
pointPen.beginPath()
pointPen.addPoint((0, 0), "move")
pointPen.addPoint((0, 100), "line")
pointPen.addPoint((100, 100), "line")
pointPen.addPoint((100, 0), "line")
pointPen.addPoint((0, 0), "line")
pointPen.endPath()
self.assertEqual(baseGlyph.area, 10000)

componentGlyph = font.newGlyph("componentGlyph")
pointPen = componentGlyph.getPointPen()
pointPen.addComponent("baseGlyph", [1, 0, 0, 1, 0, 0])
self.assertEqual(componentGlyph.area, 10000)


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion Lib/defcon/tools/representations.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _makeGlyphToGroupMapping(groups):
# -----

def glyphAreaRepresentationFactory(glyph):
pen = AreaPen()
pen = AreaPen(glyph.layer)
glyph.draw(pen)
return abs(pen.value)

Expand Down
2 changes: 0 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
environment:
matrix:
- JOB: "2.7 32-bit"
PYTHON_HOME: "C:\\Python27"

- JOB: "3.6 64-bit"
PYTHON_HOME: "C:\\Python36-x64"
Expand Down

0 comments on commit 71f1cd9

Please sign in to comment.