Basics
Guides
API Reference
Basics
Guides
API Reference
[12:14] static extends: object
Generated low-level function wrappers for namespace PangoCairo.
getLib ()
context_get_font_options (object context)
Retrieves any font rendering options previously set with [func@PangoCairo.context_set_font_options]. This function does not report options that are derived from the target surface by [func@update_context].
context is a PangoContext, from a pangocairo font map.context_get_resolution (object context)
Gets the resolution for the context. See [func@PangoCairo.context_set_resolution]
context is a PangoContext, from a pangocairo font map.context_set_font_options (object context, object options)
Sets the font options used when rendering text with this context. These options override any options that [func@update_context] derives from the target surface.
context is a PangoContext, from a pangocairo font map.options is a cairo_font_options_t, or %NULL to unset any previously set options. A copy is made..None.context_set_resolution (object context, double dpi)
Sets the resolution for the context. This is a scale factor between points specified in a
PangoFontDescriptionand Cairo units. The default value is 96, meaning that a 10 point font will be 13 units high. (10 * 96. / 72. = 13.3).
context is a PangoContext, from a pangocairo font map.dpi is the resolution in "dots per inch". (Physical inches aren't actually involved; the terminology is conventional.) A 0 or negative value means to use the resolution from the font map..None.create_context (object cr)
Creates a context object set up to match the current transformation and target surface of the Cairo context. This context can then be used to create a layout using [ctor@Pango.Layout.new]. This function is a convenience function that creates a context using the default font map, then updates it to @cr. If you just need to create a layout for use with
and do not need to access PangoContext directly, you can use [func@create_layout] instead.cr is a Cairo context.create_layout (object cr)
Creates a layout object set up to match the current transformation and target surface of the Cairo context. This layout can then be used for text measurement with functions like [method@Pango.Layout.get_size] or drawing with functions like [func@show_layout]. If you change the transformation or target surface for @cr, you need to call [func@update_layout]. This function is the most convenient way to use Cairo with Pango, however it is slightly inefficient since it creates a separate
PangoContextobject for each layout. This might matter in an application that was laying out large amounts of text.
cr is a Cairo context.error_underline_path (object cr, double x, double y, double width, double height)
Add a squiggly line to the current path in the specified cairo context that approximately covers the given rectangle in the style of an underline used to indicate a spelling error. The width of the underline is rounded to an integer number of up/down segments and the resulting rectangle is centered in the original rectangle.
cr is a Cairo context.x is The X coordinate of one corner of the rectangle.y is The Y coordinate of one corner of the rectangle.width is Non-negative width of the rectangle.height is Non-negative height of the rectangle.None.font_map_get_default ()
Gets a default
PangoCairoFontMapto use with Cairo. Note that the type of the returned object will depend on the particular font backend Cairo was compiled to use; you generally should only use thePangoFontMapandPangoCairoFontMapinterfaces on the returned object. The default Cairo fontmap can be changed by using [method@PangoCairo.FontMap.set_default]. This can be used to change the Cairo font backend that the default fontmap uses for example. Note that since Pango 1.32.6, the default fontmap is per-thread. Each thread gets its own default fontmap. In this way, PangoCairo can be used safely from multiple threads.
font_map_new ()
Creates a new
PangoCairoFontMapobject. A fontmap is used to cache information about available fonts, and holds certain global parameters such as the resolution. In most cases, you can usefunc@PangoCairo.font_map_get_default] instead. Note that the type of the returned object will depend on the particular font backend Cairo was compiled to use; You generally should only use thePangoFontMapandPangoCairoFontMap` interfaces on the returned object. You can override the type of backend returned by using an environment variable %PANGOCAIRO_BACKEND. Supported types, based on your build, are fc (fontconfig), win32, and coretext. If requested type is not available, NULL is returned. Ie. this is only useful for testing, when at least two backends are compiled in.
font_map_new_for_font_type (string fonttype)
Creates a new
PangoCairoFontMapobject of the type suitable to be used with cairo font backend of type @fonttype. In most cases one should simply use [func@PangoCairo.FontMap.new], or in fact in most of those cases, just use [func@PangoCairo.FontMap.get_default].
fonttype is desired #cairo_font_type_t.glyph_string_path (object cr, object font, object glyphs)
Adds the glyphs in @glyphs to the current path in the specified cairo context. The origin of the glyphs (the left edge of the baseline) will be at the current point of the cairo context.
cr is a Cairo context.font is a PangoFont from a PangoCairoFontMap.glyphs is a PangoGlyphString.None.layout_line_path (object cr, object line)
Adds the text in
PangoLayoutLineto the current path in the specified cairo context. The origin of the glyphs (the left edge of the line) will be at the current point of the cairo context.
cr is a Cairo context.line is a PangoLayoutLine.None.layout_path (object cr, object layout)
Adds the text in a
PangoLayoutto the current path in the specified cairo context. The top-left corner of thePangoLayoutwill be at the current point of the cairo context.
cr is a Cairo context.layout is a Pango layout.None.show_error_underline (object cr, double x, double y, double width, double height)
Draw a squiggly line in the specified cairo context that approximately covers the given rectangle in the style of an underline used to indicate a spelling error. The width of the underline is rounded to an integer number of up/down segments and the resulting rectangle is centered in the original rectangle.
cr is a Cairo context.x is The X coordinate of one corner of the rectangle.y is The Y coordinate of one corner of the rectangle.width is Non-negative width of the rectangle.height is Non-negative height of the rectangle.None.show_glyph_item (object cr, string text, object glyph_item)
Draws the glyphs in @glyph_item in the specified cairo context, embedding the text associated with the glyphs in the output if the output format supports it (PDF for example), otherwise it acts similar to [func@show_glyph_string]. The origin of the glyphs (the left edge of the baseline) will be drawn at the current point of the cairo context. Note that @text is the start of the text for layout, which is then indexed by
glyph_item->item->offset.
cr is a Cairo context.text is the UTF-8 text that @glyph_item refers to.glyph_item is a PangoGlyphItem.None.show_glyph_string (object cr, object font, object glyphs)
Draws the glyphs in @glyphs in the specified cairo context. The origin of the glyphs (the left edge of the baseline) will be drawn at the current point of the cairo context.
cr is a Cairo context.font is a PangoFont from a PangoCairoFontMap.glyphs is a PangoGlyphString.None.show_layout (object cr, object layout)
Draws a
PangoLayoutin the specified cairo context. The top-left corner of thePangoLayoutwill be drawn at the current point of the cairo context.
cr is a Cairo context.layout is a Pango layout.None.show_layout_line (object cr, object line)
Draws a
PangoLayoutLinein the specified cairo context. The origin of the glyphs (the left edge of the line) will be drawn at the current point of the cairo context.
cr is a Cairo context.line is a PangoLayoutLine.None.update_context (object cr, object context)
Updates a
PangoContextpreviously created for use with Cairo to match the current transformation and target surface of a Cairo context. If any layouts have been created for the context, it's necessary to call [method@Pango.Layout.context_changed] on those layouts.
cr is a Cairo context.context is a PangoContext, from a pangocairo font map.None.update_layout (object cr, object layout)
Updates the private
PangoContextof aPangoLayoutcreated with [func@create_layout] to match the current transformation and target surface of a Cairo context.
cr is a Cairo context.layout is a PangoLayout, from [func@create_layout].None.
Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.