FontMap#
Superclasses: Object
Implemented Interfaces: 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#
- class FontMap
- changed() None #
Forces a change in the context, 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 context and such data is changed.
Added in version 1.34.
- create_context() Context #
Creates a
PangoContext
connected tofontmap
.This is equivalent to
new
followed byset_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.Added in version 1.22.
- get_family(name: str) FontFamily #
Gets a font family by name.
Added in version 1.46.
- Parameters:
name – a family name
- get_serial() int #
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 inPangoContext
.Added in version 1.32.4.
- list_families() list[FontFamily] #
List all families for a fontmap.
Note that the returned families are not in any particular order.
PangoFontMap
also implemented theListModel
interface for enumerating families.
- load_font(context: Context, desc: FontDescription) Font | None #
Load the font in the fontmap that is the closest match for
desc
.- Parameters:
context – the
PangoContext
the font will be used withdesc – a
PangoFontDescription
describing the font to load
- load_fontset(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 – the
PangoContext
the font will be used withdesc – a
PangoFontDescription
describing the font to loadlanguage – a
PangoLanguage
the fonts will be used for
- reload_font(font: Font, scale: float, context: Context | None = None, variations: str | None = None) Font #
Returns a new font that is like
font
, except that its size is multiplied byscale
, its backend-dependent configuration (e.g. cairo font options) is replaced by the one incontext
, and its variations are replaced byvariations
.Added in version 1.52.
- Parameters:
font – a font in
fontmap
scale – the scale factor to apply
context – a
PangoContext
variations – font variations to use
Properties#
Virtual Methods#
- class FontMap
- do_changed() None #
Forces a change in the context, 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 context and such data is changed.
Added in version 1.34.
- do_get_family(name: str) FontFamily #
Gets a font family by name.
Added in version 1.46.
- Parameters:
name – a family name
- do_get_serial() int #
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 inPangoContext
.Added in version 1.32.4.
- do_list_families() list[FontFamily] #
List all families for a fontmap.
Note that the returned families are not in any particular order.
PangoFontMap
also implemented theListModel
interface for enumerating families.
- do_load_font(context: Context, desc: FontDescription) Font | None #
Load the font in the fontmap that is the closest match for
desc
.- Parameters:
context – the
PangoContext
the font will be used withdesc – a
PangoFontDescription
describing the font to load
- do_load_fontset(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 – the
PangoContext
the font will be used withdesc – a
PangoFontDescription
describing the font to loadlanguage – a
PangoLanguage
the fonts will be used for
Fields#
- class FontMap
- parent_instance#