kiva.fonttools package

class kiva.fonttools.Font(face_name='', size=12, family=1, weight=400, style=0, underline=0, encoding=0)[source]

Bases: object

Font class for device independent font specification.

It is primarily based on wxPython, but looks to be similar to the needs of Mac OS X, etc.

The family defaults to SWISS so that font rotation will work correctly under wxPython. Revisit as we get more platforms defined.

copy()[source]

Returns a copy of the font object.

familymap = {0: 'serif', 1: 'sans-serif', 2: 'serif', 3: 'sans-serif', 4: 'fantasy', 5: 'cursive', 6: 'monospace'}
findfont(language=None)[source]

Returns the file name and face index of the font that most closely matches our font properties.

Parameters

language (str [optional]) – If provided, attempt to find a font which supports language.

findfontname(language=None)[source]

Returns the name of the font that most closely matches our font properties.

Parameters

language (str [optional]) – If provided, attempt to find a font which supports language.

is_bold()[source]

Is the font considered bold or not?

This is a convenience method for backends which don’t fully support font weights. We consider a font to be bold if its weight is more than medium.

property name
kiva.fonttools.add_application_fonts(filenames)[source]

Add a TrueType font to the system in a way that makes it available to both the GUI toolkit and Kiva.

Parameters

filenames (list of str) – Filesystem paths of TrueType or OpenType font files.

kiva.fonttools.str_to_font(fontspec, parser=<function simple_parser>)[source]

Converts a string specification of a font into a Font instance. string specifications are of the form: “modern 12”, “9 roman italic”, and so on.