Representation of a single glyph including contour extraction
||Object encapsulating metadata regarding a particular glyph|
||Methods defined here:|
- __init__(self, glyphName)
- Initialize the glyph object
glyphName -- font's glyphName for this glyph, see
glyphquery.glyphName() for extracting the
appropriate name from character and encoding.
- calculateContours(self, font)
- Given a character, determine contours to draw
returns a list of contours, with each contour
being a list of ((x,y),flag) elements. There may
be only a single contour.
- compile(self, font, steps=3)
- Compile the glyph to a set of poly-line outlines
Data descriptors defined here:
- dictionary for instance variables (if defined)
- list of weak references to the object (if defined)
- decomposeOutline(contour, steps=3)
- Decompose a single TrueType contour to a line-loop
In essence, this is the "interpretation" of the font
as geometric primitives. I only support line and
quadratic (conic) segments, which should support most
TrueType fonts as far as I know.
The process consists of first scanning for any multi-
of-curve control-point runs. For each pair of such
control points, we insert a new on-curve control point.
Once we have the "expanded" control point array we
scan through looking for each segment which includes
an off-curve control point. These should only be
bracketed by on-curve control points. For each
found segment, we call our integrateQuadratic method
to produce a set of points interpolating between the
end points as affected by the middle control point.
All other control points merely generate a single
line-segment between the endpoints.
- integrateQuadratic(points, steps=3)
- Get points on curve for quadratic w/ end points A and C
Basis Equations are taken from here:
This is a very crude approach to the integration,
everything is coded directly in Python, with no
attempts to speed up the process.
XXX Should eventually provide adaptive steps so that
the angle between the elements can determine how
many steps are used.
||__file__ = '/home/mcfletch/pylive/ttfquery/glyph.pyc'|
__name__ = 'ttfquery.glyph'
__package__ = 'ttfquery'