interpreting glyph outlines from ttfquery?

Wojciech Muła wojciech_mula at poczta.null.onet.pl.invalid
Thu Mar 22 12:26:38 CET 2007


swiftset wrote:
> I'm try to convert a glyph into a format I can easily numerically
> manipulate. So far I've figured out how to use ttfquery to get a list
> that represents the outline of a contour in a glyph:
> 
> from ttfquery import describe, glyphquery, glyph
> f = describe.openFont("/usr/share/fonts/truetype/freefont/
> FreeSans.ttf")
> n = glyphquery.glyphName(f, 'D')
> g = glyph.Glyph(n)
> c = g.calculateContours(f)
> o = glyph.decomposeOutline(c[1])
> 
> o looks like:
> 
> [array([182,  82],'s'),
> (354, 82),
> (420.22222222222229, 90.000000000000014),
> (474.88888888888891, 114.0), ...,
> array([182,  82],'s'),
> array([182,  82],'s')]
> 
> Is this a polyline?

decomposeOutline docstring confirms -- it's a polyline.  I think 
elements marked with 's' starts new subpath.

w.



More information about the Python-list mailing list