Pango.FontMap¶
class — extends GObject.Object, Gio.ListModel
A PangoFontMap represents the set of fonts available for a
particular rendering system.
This is a virtual object with implementations being specific to particular rendering systems.
Methods¶
add_font_file¶
Loads a font file with one or more fonts into the PangoFontMap.
The added fonts will take precedence over preexisting fonts with the same name.
Parameters:
filename— Path to the font file
changed¶
Forces a change in the fontmap, which will cause any PangoContext
using this fontmap to change.
This function is only useful when implementing a new backend for Pango, something applications won't do. Backends should call this function if they have attached extra data to the fontmap and such data is changed.
create_context¶
Creates a PangoContext connected to fontmap.
This is equivalent to Context.new followed by
Context.set_font_map.
If you are using Pango as part of a higher-level system,
that system may have it's own way of create a PangoContext.
For instance, the GTK toolkit has, among others,
Gtk.Widget.get_pango_context. Use those instead.
get_family¶
Gets a font family by name.
Parameters:
name— a family name
get_serial¶
Returns the current serial number of fontmap.
The serial number is initialized to an small number larger than zero when a new fontmap is created and is increased whenever the fontmap is changed. It may wrap, but will never have the value 0. Since it can wrap, never compare it with "less than", always use "not equals".
The fontmap can only be changed using backend-specific API, like changing fontmap resolution.
This can be used to automatically detect changes to a PangoFontMap,
like in PangoContext.
list_families¶
List all families for a fontmap.
Note that the returned families are not in any particular order.
PangoFontMap also implemented the Gio.ListModel interface
for enumerating families.
load_font¶
Load the font in the fontmap that is the closest match for desc.
Parameters:
context— thePangoContextthe font will be used withdesc— aPangoFontDescriptiondescribing the font to load
load_fontset¶
def load_fontset(self, context: Context, desc: FontDescription, language: Language) -> Fontset | None
Load a set of fonts in the fontmap that can be used to render
a font matching desc.
Parameters:
context— thePangoContextthe font will be used withdesc— aPangoFontDescriptiondescribing the font to loadlanguage— aPangoLanguagethe fonts will be used for
reload_font¶
def reload_font(self, font: Font, scale: float, context: Context | None = ..., variations: str | None = ...) -> Font
Returns a new font that is like font, except that it is scaled
by scale, its backend-dependent configuration (e.g. cairo font options)
is replaced by the one in context, and its variations are replaced
by variations.
Note that the scaling here is meant to be linear, so this scaling can be used to render a font on a hi-dpi display without changing its optical size.
Parameters:
font— a font infontmapscale— the scale factor to applycontext— aPangoContextvariations— font variations to use
Virtual methods¶
do_changed¶
Forces a change in the fontmap, which will cause any PangoContext
using this fontmap to change.
This function is only useful when implementing a new backend for Pango, something applications won't do. Backends should call this function if they have attached extra data to the fontmap and such data is changed.
do_get_family¶
Gets a font family by name.
Parameters:
name— a family name
do_get_serial¶
Returns the current serial number of fontmap.
The serial number is initialized to an small number larger than zero when a new fontmap is created and is increased whenever the fontmap is changed. It may wrap, but will never have the value 0. Since it can wrap, never compare it with "less than", always use "not equals".
The fontmap can only be changed using backend-specific API, like changing fontmap resolution.
This can be used to automatically detect changes to a PangoFontMap,
like in PangoContext.
do_list_families¶
List all families for a fontmap.
Note that the returned families are not in any particular order.
PangoFontMap also implemented the Gio.ListModel interface
for enumerating families.
do_load_font¶
Load the font in the fontmap that is the closest match for desc.
Parameters:
context— thePangoContextthe font will be used withdesc— aPangoFontDescriptiondescribing the font to load
do_load_fontset¶
def do_load_fontset(self, context: Context, desc: FontDescription, language: Language) -> Fontset | None
Load a set of fonts in the fontmap that can be used to render
a font matching desc.
Parameters:
context— thePangoContextthe font will be used withdesc— aPangoFontDescriptiondescribing the font to loadlanguage— aPangoLanguagethe fonts will be used for
Properties¶
item_type¶
The type of items contained in this list.
n_items¶
The number of items contained in this list.