Automatically add to Imlib2’s font path any directory known by FontConfig to contain TrueType fonts.
Warning
This function spawns fc-list which can take some time to execute with a cold cache.
Add the given path to the list of paths to scan when loading fonts.
Parameter: | path (str) – directory containing fonts |
---|
Load a TrueType font from the first directory in the font path that contains the specified font.
Parameters: |
|
---|---|
Raises: | IOError if the font could not be loaded. |
Returns: | Font object |
Return the additional size in pixels needed for the given style.
Parameter: | style – one of the TEXT_STYLE constants |
---|---|
Returns: | 6-tuple (left, top, right, bottom, width, height) |
Width and height are included as a convenience, but they are just the sum of left+right and top+bottom.
On Python 2.6 and later this function will return a named tuple.
These constants are used with imlib2.Image.draw_text() and imlib2.Font.set_style().
Font class representing an Imlib2 Font object. Font objects may be assigned to Image objects via their font property to control font, size, and style to draw_text() operations.
Parameters: |
|
---|
Font paths can be registered by calling add_font_path() or auto_set_font_path().
Once a Font object is instantiated the font name cannot be changed, however the size can be changed by adjusting the size property.
imlib2.Font
get_style_geometry() | Return the additional size in pixels needed for the current style. |
---|---|
get_text_size() | Calculate font metrics (size and advance) for the specified text when rendered by the current font. |
set_color() | Deprecated: use the color property instead. |
set_size() | Deprecated: use the size property instead. |
set_style() | Set the default text style for future text rendered with this font. |
ascent | read-only | The number of pixels from the baseline to the top of the text for nominal characters. |
---|---|---|
color | read/write | A 4-tuple containing the red, green, blue, and alpha values from 0-255. |
descent | read-only | The number of pixels from the baseline to the bottom of the text for nominal characters. |
max_ascent | read-only | The maximum ascent for all glyphs in the font. |
max_descent | read-only | The maximum descent for all glyphs in the font. |
name | read-only | The file name of the font (without the .ttf extension), e.g. VeraBd |
size | read/write | The size in pixels of the font. |
Return the additional size in pixels needed for the current style.
See get_font_style_geometry() for more details.
Calculate font metrics (size and advance) for the specified text when rendered by the current font.
Parameter: | text (str or unicode) – the text whose metrics to calculate |
---|---|
Returns: | 4-tuple (width, height, horizontal advance, vertical advance) |
Set the default text style for future text rendered with this font.
Parameters: |
|
---|
A 4-tuple containing the red, green, blue, and alpha values from 0-255.
This property may be set to any value accepted by normalize_color(), but it will always be converted to a 4-tuple.