ttfquery.ttffiles
Registry of available TrueType font files
XXX Currently two copies of exactly the same font
will likely confuse the registry because the
specificFonts set will only have one of the
metrics sets. Nothing breaks at the moment
because of this, but it's not ideal.
Functions
Classes
Object providing centralized registration of TTF files
Attributes:
families -- mapping from TrueType font families
to sub-families and then to general fonts
(as a set of font-names).
fonts -- mapping from general fonts to modifiers to
specific font instances
specificFonts -- mapping from specific font names
to the entire "metrics" set for the particular
font.
files -- mapping from (absolute) filenames to
specific font names
shortFiles -- mapping from font filename basenames
to font-file-lists
DIRTY -- flag indicating whether the registry has
had a new font registered (i.e. whether it should
be saved out to disk).
fontMembers(
self
,
fontName
,
weight
= None
,
italics
= None
)
Get specific font names for given generic font name
- weight
- if specified, only members with the given weight
- italics
- if specified, only members where the flag matches
returns list of specific font names
load(
self
,
file
,
clearFirst
= 1
)
Attempt to load the font metadata from a pickled file
- file
- a file open in binary read mode or a filename
- clearFirst
- if true, clear tables first, and reset DIRTYto 0 after finished
metadata(
self
,
filename
,
force
= 0
)
Retrieve metadata from font file
- filename
- fully specified path to the font file
- force
- if false, and the metadata is alreadyavailable for this file, do not access thefont file to retrieve, just return the existingmetadata.
return value:
tuple of:
filename -- fully specified absolute path
modifiers -- (weightInteger, italicsFlag)
specificName -- specific name of the particular
font stored in the given file, the name of
the "modified" font
fontName -- name of the general font which
the modifiers are specialising
specifier -- family specifier, two-tuple of
high-level and sub-level font classifications
based on font characteristics as encoded
in the font file.
register(
self
,
filename
,
modifiers
= None
,
specificName
= None
,
fontName
= None
,
familySpecifier
= None
,
force
= 0
)
Do the actual registration of a filename & metadata
See metadata function for description of the various
arguments. If modifiers == None then the metadata function
will be used to scan for the metadata.
- force
- if true, force re-reading font-file even if we already have the meta-data for the file loaded.