Document new pens
This commit is contained in:
parent
19ab2c96cc
commit
c2033cb095
@ -1,3 +1,5 @@
|
|||||||
|
"""Pen calculating 0th, 1st, and 2nd moments of area of glyph shapes.
|
||||||
|
This is low-level, autogenerated pen. Use statisticsPen instead."""
|
||||||
from __future__ import print_function, division, absolute_import
|
from __future__ import print_function, division, absolute_import
|
||||||
from fontTools.misc.py23 import *
|
from fontTools.misc.py23 import *
|
||||||
from fontTools.pens.basePen import BasePen
|
from fontTools.pens.basePen import BasePen
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
"""Pen recording operations that can be accessed or replayed."""
|
||||||
from __future__ import print_function, division, absolute_import
|
from __future__ import print_function, division, absolute_import
|
||||||
from fontTools.misc.py23 import *
|
from fontTools.misc.py23 import *
|
||||||
from fontTools.pens.basePen import AbstractPen
|
from fontTools.pens.basePen import AbstractPen
|
||||||
@ -7,6 +8,11 @@ __all__ = ["RecordingPen"]
|
|||||||
|
|
||||||
|
|
||||||
class RecordingPen(AbstractPen):
|
class RecordingPen(AbstractPen):
|
||||||
|
"""Pen recording operations that can be accessed or replayed.
|
||||||
|
|
||||||
|
The recording can be accessed as pen.value; or replayed using
|
||||||
|
pen.replay(otherPen)."""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.value = []
|
self.value = []
|
||||||
def moveTo(self, p0):
|
def moveTo(self, p0):
|
||||||
@ -23,7 +29,6 @@ class RecordingPen(AbstractPen):
|
|||||||
self.value.append(('endPath', ()))
|
self.value.append(('endPath', ()))
|
||||||
def addComponent(self, glyphName, transformation):
|
def addComponent(self, glyphName, transformation):
|
||||||
self.value.append(('addComponent', (glyphName, transformation)))
|
self.value.append(('addComponent', (glyphName, transformation)))
|
||||||
|
|
||||||
def replay(self, pen):
|
def replay(self, pen):
|
||||||
for operator,operands in self.value:
|
for operator,operands in self.value:
|
||||||
getattr(pen, operator)(*operands)
|
getattr(pen, operator)(*operands)
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
"""Pen calculating area, center of mass, variance and standard-deviation,
|
||||||
|
covariance and correlation, and slant, of glyph shapes."""
|
||||||
from __future__ import print_function, division, absolute_import
|
from __future__ import print_function, division, absolute_import
|
||||||
from fontTools.misc.py23 import *
|
from fontTools.misc.py23 import *
|
||||||
import math
|
import math
|
||||||
@ -8,6 +10,16 @@ __all__ = ["StatisticsPen"]
|
|||||||
|
|
||||||
class StatisticsPen(MomentsPen):
|
class StatisticsPen(MomentsPen):
|
||||||
|
|
||||||
|
"""Pen calculating area, center of mass, variance and
|
||||||
|
standard-deviation, covariance and correlation, and slant,
|
||||||
|
of glyph shapes.
|
||||||
|
|
||||||
|
Note that all the calculated values are 'signed'. Ie. if the
|
||||||
|
glyph shape is self-intersecting, the values are not correct
|
||||||
|
(but well-defined). As such, area will be negative if contour
|
||||||
|
directions are clockwise. Moreover, variance might be negative
|
||||||
|
if the shapes are self-intersecting in certain ways."""
|
||||||
|
|
||||||
def __init__(self, glyphset=None):
|
def __init__(self, glyphset=None):
|
||||||
MomentsPen.__init__(self, glyphset=glyphset)
|
MomentsPen.__init__(self, glyphset=glyphset)
|
||||||
self.__zero()
|
self.__zero()
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
"""Pen multiplexing drawing to one or more pens."""
|
||||||
from __future__ import print_function, division, absolute_import
|
from __future__ import print_function, division, absolute_import
|
||||||
from fontTools.misc.py23 import *
|
from fontTools.misc.py23 import *
|
||||||
from fontTools.pens.basePen import AbstractPen
|
from fontTools.pens.basePen import AbstractPen
|
||||||
@ -7,6 +8,10 @@ __all__ = ["TeePen"]
|
|||||||
|
|
||||||
|
|
||||||
class TeePen(AbstractPen):
|
class TeePen(AbstractPen):
|
||||||
|
"""Pen multiplexing drawing to one or more pens.
|
||||||
|
|
||||||
|
Use either as TeePen(pen1, pen2, ...) or TeePen(iterableOfPens)."""
|
||||||
|
|
||||||
def __init__(self, *pens):
|
def __init__(self, *pens):
|
||||||
if len(pens) == 1:
|
if len(pens) == 1:
|
||||||
pens = pens[0]
|
pens = pens[0]
|
||||||
|
1
NEWS.rst
1
NEWS.rst
@ -1,3 +1,4 @@
|
|||||||
|
- New pens: MomentsPen, StatisticsPen, RecordingPen, and TeePen.
|
||||||
- [varLib] designspace.load() now returns a dictionary, instead of a tuple,
|
- [varLib] designspace.load() now returns a dictionary, instead of a tuple,
|
||||||
and supports <axes> element (#864)
|
and supports <axes> element (#864)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user