Pango.Font¶
class — extends GObject.Object
A PangoFont is used to represent a font in a
rendering-system-independent manner.
Methods¶
describe¶
Returns a description of the font, with font size set in points.
Use Font.describe_with_absolute_size if you want
the font size in device units.
describe_with_absolute_size¶
Returns a description of the font, with absolute font size set in device units.
Use Font.describe if you want the font size in points.
get_coverage¶
Computes the coverage map for a given font and language tag.
Parameters:
language— the language tag
get_face¶
Gets the PangoFontFace to which font belongs.
Note that this function can return NULL in cases
where the font outlives its font map.
get_features¶
Obtain the OpenType features that are provided by the font.
These are passed to the rendering system, together with features that have been explicitly set via attributes.
Note that this does not include OpenType features which the rendering system enables by default.
Parameters:
num_features— the number of used items infeatures
get_font_map¶
Gets the font map for which the font was created.
Note that the font maintains a weak reference to
the font map, so if all references to font map are
dropped, the font map will be finalized even if there
are fonts created with the font map that are still alive.
In that case this function will return None.
It is the responsibility of the user to ensure that the
font map is kept alive. In most uses this is not an issue
as a PangoContext holds a reference to the font map.
get_glyph_extents¶
Gets the logical and ink extents of a glyph within a font.
The coordinate system for each rectangle has its origin at the base line and horizontal origin of the character with increasing coordinates extending to the right and down. The macros PANGO_ASCENT(), PANGO_DESCENT(), PANGO_LBEARING(), and PANGO_RBEARING() can be used to convert from the extents rectangle to more traditional font metrics. The units of the rectangles are in 1/PANGO_SCALE of a device unit.
If font is None, this function gracefully sets some sane values in the
output variables and returns.
Parameters:
glyph— the glyph index
get_languages¶
Returns the languages that are supported by font.
If the font backend does not provide this information,
None is returned. For the fontconfig backend, this
corresponds to the FC_LANG member of the FcPattern.
The returned array is only valid as long as the font and its fontmap are valid.
get_metrics¶
Gets overall metric information for a font.
Since the metrics may be substantially different for different scripts, a language tag can be provided to indicate that the metrics should be retrieved that correspond to the script(s) used by that language.
If font is None, this function gracefully sets some sane values in the
output variables and returns.
Parameters:
language— language tag used to determine which script to get the metrics for, orNoneto indicate to get the metrics for the entire font.
has_char¶
Returns whether the font provides a glyph for this character.
Parameters:
wc— a Unicode character
serialize¶
Serializes the font in a way that can be uniquely identified.
There are no guarantees about the format of the output across different versions of Pango.
The intended use of this function is testing, benchmarking and debugging. The format is not meant as a permanent storage format.
To recreate a font from its serialized form, use Font.deserialize.
Static functions¶
descriptions_free¶
:::warning Deprecated since 1.56 This API is deprecated. :::
Frees an array of font descriptions.
Parameters:
descs— a pointer to an array ofPangoFontDescription, may beNone
deserialize¶
Loads data previously created via Font.serialize.
For a discussion of the supported format, see that function.
Note: to verify that the returned font is identical to
the one that was serialized, you can compare bytes to the
result of serializing the font again.
Parameters:
context— aPangoContextbytes— the bytes containing the data
Virtual methods¶
do_create_hb_font¶
do_describe¶
Returns a description of the font, with font size set in points.
Use Font.describe_with_absolute_size if you want
the font size in device units.
do_describe_absolute¶
do_get_coverage¶
Computes the coverage map for a given font and language tag.
Parameters:
language— the language tag
do_get_features¶
Obtain the OpenType features that are provided by the font.
These are passed to the rendering system, together with features that have been explicitly set via attributes.
Note that this does not include OpenType features which the rendering system enables by default.
Parameters:
num_features— the number of used items infeatures
do_get_font_map¶
Gets the font map for which the font was created.
Note that the font maintains a weak reference to
the font map, so if all references to font map are
dropped, the font map will be finalized even if there
are fonts created with the font map that are still alive.
In that case this function will return None.
It is the responsibility of the user to ensure that the
font map is kept alive. In most uses this is not an issue
as a PangoContext holds a reference to the font map.
do_get_glyph_extents¶
Gets the logical and ink extents of a glyph within a font.
The coordinate system for each rectangle has its origin at the base line and horizontal origin of the character with increasing coordinates extending to the right and down. The macros PANGO_ASCENT(), PANGO_DESCENT(), PANGO_LBEARING(), and PANGO_RBEARING() can be used to convert from the extents rectangle to more traditional font metrics. The units of the rectangles are in 1/PANGO_SCALE of a device unit.
If font is None, this function gracefully sets some sane values in the
output variables and returns.
Parameters:
glyph— the glyph index
do_get_metrics¶
Gets overall metric information for a font.
Since the metrics may be substantially different for different scripts, a language tag can be provided to indicate that the metrics should be retrieved that correspond to the script(s) used by that language.
If font is None, this function gracefully sets some sane values in the
output variables and returns.
Parameters:
language— language tag used to determine which script to get the metrics for, orNoneto indicate to get the metrics for the entire font.