Pango.Font¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
|
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Pango.Font(**kwargs)¶
- Bases:
- Abstract:
Yes
- Structure:
A
PangoFont
is used to represent a font in a rendering-system-independent manner.- classmethod descriptions_free(descs)[source]¶
- Parameters:
descs ([
Pango.FontDescription
] orNone
) – a pointer to an array ofPangoFontDescription
, may beNone
Frees an array of font descriptions.
- classmethod deserialize(context, bytes)[source]¶
- Parameters:
context (
Pango.Context
) – aPangoContext
bytes (
GLib.Bytes
) – the bytes containing the data
- Raises:
- Returns:
a new
PangoFont
- Return type:
Pango.Font
orNone
Loads data previously created via [method`Pango`.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.
New in version 1.50.
- describe()[source]¶
- Returns:
a newly-allocated
PangoFontDescription
object.- Return type:
Returns a description of the font, with font size set in points.
Use [method`Pango`.Font.describe_with_absolute_size] if you want the font size in device units.
- describe_with_absolute_size()[source]¶
- Returns:
a newly-allocated
PangoFontDescription
object.- Return type:
Returns a description of the font, with absolute font size set in device units.
Use [method`Pango`.Font.describe] if you want the font size in points.
New in version 1.14.
- get_coverage(language)[source]¶
- Parameters:
language (
Pango.Language
) – the language tag- Returns:
a newly-allocated
PangoCoverage
object.- Return type:
Computes the coverage map for a given font and language tag.
- get_face()[source]¶
- Returns:
the
PangoFontFace
- Return type:
Gets the
PangoFontFace
to which self belongs.New in version 1.46.
- get_features(num_features)[source]¶
- Parameters:
num_features (
int
) – the number of used items in features- Returns:
- features:
Array to features in
- num_features:
the number of used items in features
- Return type:
(features: [
HarfBuzz.feature_t
], num_features:int
)
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.
New in version 1.44.
- get_font_map()[source]¶
- Returns:
the
PangoFontMap
for the font- Return type:
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.New in version 1.10.
- get_glyph_extents(glyph)[source]¶
- Parameters:
glyph (
int
) – the glyph index- Returns:
- ink_rect:
rectangle used to store the extents of the glyph as drawn
- logical_rect:
rectangle used to store the logical extents of the glyph
- Return type:
(ink_rect:
Pango.Rectangle
, logical_rect:Pango.Rectangle
)
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 self is
None
, this function gracefully sets some sane values in the output variables and returns.
- get_languages()[source]¶
- Returns:
an array of
PangoLanguage
- Return type:
[
Pango.Language
] orNone
Returns the languages that are supported by self.
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.
New in version 1.50.
- get_metrics(language)[source]¶
- Parameters:
language (
Pango.Language
orNone
) – language tag used to determine which script to get the metrics for, orNone
to indicate to get the metrics for the entire font.- Returns:
a
PangoFontMetrics
object. The caller must call [method`Pango`.FontMetrics.unref] when finished using the object.- Return type:
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 self is
None
, this function gracefully sets some sane values in the output variables and returns.
- has_char(wc)[source]¶
-
Returns whether the font provides a glyph for this character.
New in version 1.44.
- serialize()[source]¶
- Returns:
a
GBytes
containing the serialized form of self- Return type:
Serializes the self 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 [func`Pango`.Font.deserialize].
New in version 1.50.
- do_create_hb_font() virtual¶
- Return type:
- do_describe() virtual¶
- Returns:
a newly-allocated
PangoFontDescription
object.- Return type:
Returns a description of the font, with font size set in points.
Use [method`Pango`.Font.describe_with_absolute_size] if you want the font size in device units.
- do_describe_absolute() virtual¶
- Return type:
- do_get_coverage(language) virtual¶
- Parameters:
language (
Pango.Language
) – the language tag- Returns:
a newly-allocated
PangoCoverage
object.- Return type:
Computes the coverage map for a given font and language tag.
- do_get_features(num_features) virtual¶
- Parameters:
num_features (
int
) – the number of used items in features- Returns:
- features:
Array to features in
- num_features:
the number of used items in features
- Return type:
(features: [
HarfBuzz.feature_t
], num_features:int
)
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.
New in version 1.44.
- do_get_font_map() virtual¶
- Returns:
the
PangoFontMap
for the font- Return type:
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.New in version 1.10.
- do_get_glyph_extents(glyph) virtual¶
- Parameters:
glyph (
int
) – the glyph index- Returns:
- ink_rect:
rectangle used to store the extents of the glyph as drawn
- logical_rect:
rectangle used to store the logical extents of the glyph
- Return type:
(ink_rect:
Pango.Rectangle
, logical_rect:Pango.Rectangle
)
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.
- do_get_metrics(language) virtual¶
- Parameters:
language (
Pango.Language
orNone
) – language tag used to determine which script to get the metrics for, orNone
to indicate to get the metrics for the entire font.- Returns:
a
PangoFontMetrics
object. The caller must call [method`Pango`.FontMetrics.unref] when finished using the object.- Return type:
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.