Changeset 1059
- Timestamp:
- 12/15/11 19:48:00 (17 months ago)
- Location:
- packages/defcon/branches/ufo3/Lib/defcon
- Files:
-
- 1 added
- 1 edited
-
objects/glyph.py (modified) (6 diffs)
-
pens/decomposeComponentPointPen.py (added)
Legend:
- Unmodified
- Added
- Removed
-
packages/defcon/branches/ufo3/Lib/defcon/objects/glyph.py
r1057 r1059 6 6 from defcon.objects.point import Point 7 7 from defcon.objects.component import Component 8 from defcon.objects.component import _defaultTransformation as _defaultComponentTransformation9 8 from defcon.objects.anchor import Anchor 10 9 from defcon.objects.lib import Lib … … 13 12 from defcon.objects.color import Color 14 13 from defcon.tools.representations import glyphBoundsRepresentationFactory, glyphControlPointBoundsRepresentationFactory 14 from defcon.pens.decomposeComponentPointPen import DecomposeComponentPointPen 15 15 16 16 def addRepresentationFactory(name, factory): … … 634 634 self.holdNotifications() 635 635 layer = self.layer 636 pointPen = self.getPointPen()636 pointPen = DecomposeComponentPointPen(self, layer) 637 637 self._decomposeComponent(component, layer, pointPen) 638 638 self.releaseHeldNotifications() … … 653 653 self.holdNotifications() 654 654 layer = self.layer 655 pointPen = self.getPointPen()655 pointPen = DecomposeComponentPointPen(self, layer) 656 656 for component in self.components: 657 657 self._decomposeComponent(component, layer, pointPen) … … 660 660 661 661 def _decomposeComponent(self, component, layer, pointPen): 662 from robofab.pens.adapterPens import TransformPointPen663 662 pointPen.skipConflictingIdentifiers = True 664 baseGlyph = component.baseGlyph 665 if baseGlyph in layer: 666 baseGlyph = layer[baseGlyph] 667 if component.transformation == _defaultComponentTransformation: 668 baseGlyph.drawPoints(pointPen) 669 else: 670 transformPointPen = TransformPointPen(pointPen, component.transformation) 671 baseGlyph.drawPoints(transformPointPen) 663 component.drawPoints(pointPen) 672 664 self.removeComponent(component) 673 665 … … 1754 1746 >>> referenceGlyph[1].identifier 1755 1747 >>> referenceGlyph[1][0].identifier 1748 1749 >>> from defcon import Font 1750 >>> font = Font() 1751 1752 # nested components 1753 1754 >>> font.newGlyph("baseGlyph") 1755 >>> baseGlyph = font["baseGlyph"] 1756 >>> pointPen = baseGlyph.getPointPen() 1757 >>> pointPen.beginPath(identifier="contour1") 1758 >>> pointPen.addPoint((0, 0), "move", identifier="point1") 1759 >>> pointPen.addPoint((0, 100), "line") 1760 >>> pointPen.addPoint((100, 100), "line") 1761 >>> pointPen.addPoint((100, 0), "line") 1762 >>> pointPen.addPoint((0, 0), "line") 1763 >>> pointPen.endPath() 1764 1765 >>> font.newGlyph("referenceGlyph1") 1766 >>> referenceGlyph1 = font["referenceGlyph1"] 1767 >>> pointPen = referenceGlyph1.getPointPen() 1768 >>> pointPen.addComponent("baseGlyph", (1, 0, 0, 1, 3, 6)) 1769 >>> font.newGlyph("referenceGlyph2") 1770 >>> referenceGlyph2 = font["referenceGlyph2"] 1771 >>> pointPen = referenceGlyph2.getPointPen() 1772 >>> pointPen.addComponent("referenceGlyph1", (1, 0, 0, 1, 10, 20)) 1773 >>> referenceGlyph2.decomposeAllComponents() 1774 >>> len(referenceGlyph2.components) 1775 0 1776 >>> len(referenceGlyph1.components) 1777 1 1778 >>> len(referenceGlyph2) 1779 1 1780 >>> referenceGlyph2.bounds 1781 (13, 26, 113, 126) 1756 1782 """ 1757 1783
Note: See TracChangeset
for help on using the changeset viewer.
