Pango.Font

g GObject.Object GObject.Object Pango.Font Pango.Font GObject.Object->Pango.Font

Subclasses:None

Methods

Inherited:GObject.Object (37)
Structs:GObject.ObjectClass (5)
class descriptions_free (descs)
  describe ()
  describe_with_absolute_size ()
  find_shaper (language, ch)
  get_coverage (language)
  get_font_map ()
  get_glyph_extents (glyph)
  get_metrics (language)
  has_char (wc)

Virtual Methods

Inherited:GObject.Object (7)
  do_describe ()
  do_describe_absolute ()
  do_get_coverage (language)
  do_get_font_map ()
  do_get_glyph_extents (glyph)
  do_get_metrics (language)

Properties

None

Signals

Inherited:GObject.Object (1)

Fields

Inherited:GObject.Object (1)
Name Type Access Description
parent_instance GObject.Object r  

Class Details

class Pango.Font(**kwargs)
Bases:GObject.Object
Abstract:Yes
Structure:Pango.FontClass

The Pango.Font structure is used to represent a font in a rendering-system-independent matter. To create an implementation of a Pango.Font, the rendering-system specific code should allocate a larger structure that contains a nested Pango.Font, fill in the klass member of the nested Pango.Font with a pointer to a appropriate Pango.FontClass, then call pango_font_init() on the structure.

The Pango.Font structure contains one member which the implementation fills in.

classmethod descriptions_free(descs)[source]
Parameters:descs ([Pango.FontDescription] or None) – a pointer to an array of Pango.FontDescription, may be None

Frees an array of font descriptions.

describe()[source]
Returns:a newly-allocated Pango.FontDescription object.
Return type:Pango.FontDescription

Returns a description of the font, with font size set in points. Use Pango.Font.describe_with_absolute_size() if you want the font size in device units.

describe_with_absolute_size()[source]
Returns:a newly-allocated Pango.FontDescription object.
Return type:Pango.FontDescription

Returns a description of the font, with absolute font size set (in device units). Use Pango.Font.describe() if you want the font size in points.

New in version 1.14.

find_shaper(language, ch)[source]
Parameters:
Returns:

the best matching shaper.

Return type:

Pango.EngineShape

Finds the best matching shaper for a font for a particular language tag and character point.

Deprecated since version ???: Shape engines are no longer used

get_coverage(language)[source]
Parameters:language (Pango.Language) – the language tag
Returns:a newly-allocated Pango.Coverage object.
Return type:Pango.Coverage

Computes the coverage map for a given font and language tag.

get_font_map()[source]
Returns:the Pango.FontMap for the font, or None if self is None.
Return type:Pango.FontMap or None

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 Pango.Context 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 or None to indicate that the result is not needed.
logical_rect:rectangle used to store the logical extents of the glyph or None to indicate that the result is not needed.
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_metrics(language)[source]
Parameters:language (Pango.Language or None) – language tag used to determine which script to get the metrics for, or None to indicate to get the metrics for the entire font.
Returns:a Pango.FontMetrics object. The caller must call Pango.FontMetrics.unref() when finished using the object.
Return type:Pango.FontMetrics

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]
Parameters:wc (str) – a Unicode character
Return type:bool

Returns whether the font provides a glyph for this character.

Returns True if self can render wc

New in version 1.44.

do_describe() virtual
Returns:a newly-allocated Pango.FontDescription object.
Return type:Pango.FontDescription

Returns a description of the font, with font size set in points. Use Pango.Font.describe_with_absolute_size() if you want the font size in device units.

do_describe_absolute() virtual
Return type:Pango.FontDescription
do_get_coverage(language) virtual
Parameters:language (Pango.Language) – the language tag
Returns:a newly-allocated Pango.Coverage object.
Return type:Pango.Coverage

Computes the coverage map for a given font and language tag.

do_get_font_map() virtual
Returns:the Pango.FontMap for the font, or None if font is None.
Return type:Pango.FontMap or None

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 Pango.Context 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 or None to indicate that the result is not needed.
logical_rect:rectangle used to store the logical extents of the glyph or None to indicate that the result is not needed.
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 or None) – language tag used to determine which script to get the metrics for, or None to indicate to get the metrics for the entire font.
Returns:a Pango.FontMetrics object. The caller must call Pango.FontMetrics.unref() when finished using the object.
Return type:Pango.FontMetrics

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.