OpenGLContext.scenegraph.text._toolsfont
fonttools-based direct extraction of TTF outlines
Most of the complexity of this module has been refactored
into the ttfquery package, which provides for finding
system fonts, generating registries of available fonts,
querying metadata regarding a particular font/glyph etc.
Classes
Holder for metadata regarding a particular font
XXX Note: currently there is no distinction between the
Context-specific metadata and the generic descriptions
of the fonts. For instance, there is no reason that
the underlying glyph metadata needs to be queried for
each quality level of a given font (only the outlines
need to be regenerated), and the outlines themselves
are not actually dependent on the context, so they can
be shared across contexts, with only the display lists
not being shareable.
__init__(
self
,
filename
,
encoding
= None
,
glyphClass
= None
,
quality
= 3
)
Initialize the font
- filename
- a file source from which to load the .ttf file, must be a simple local filename, not a URL or font-name.
- encoding
- the TrueType encoding specifier, the specifier is two elements, a PlatformID and a platform-specific ID code (sub encoding). http://developer.apple.com/fonts/TTRefMan/RM06/Chap6name.html#ID the default should be the Unicode Roman if I've done my homework correctly.
(0,0) or (0,3) -- Unicode (default or Unicode 2.0
semantics respectively), I have no fonts with which
to test this encoding.
(3,1) -- Latin-1 Microsoft encoding, while
(1,0) should be the Mac-Roman encoding. You will
almost certainly want (3,1) on windows, and I'm
guessing (1,0) on Mac.
glyphClass -- the class used for creating new glyphs,
if not provided, self.defaultGlyphClass is used.
quality -- rendering quality for the font, the number
of integration steps for each quadratic curve in
the font definition.
_createGlyphs(
self
,
set
)
Create glyphs for the sequence of passed characters (called via withFont)
_generalMetadata(
self
)
Load general meta-data for this font (called via withFont)
Guess the appropriate encoding, query line height,
and character height.
ensureGlyphs(
self
,
string
)
Retrieve set of glyphs for the string from file into local cache
(Optimization), take all glyphs represented by the string
and compile each glyph not currently available with a
single opening of the font file.