2 Functions

Procedure: context-get-font-options context ⇒ %return

Retrieves any font rendering options previously set with context-set-font-options.

This function does not report options that are derived from the target surface by update_context.

context

Passed: a <PangoContext>.

a <PangoContext>, from a pangocairo font map

%return

Returned: a <CairoFontOptions>, or #f.

the font options previously set on the context, or #f if no options have been set. This value is owned by the context and must not be modified or freed.

Procedure: context-get-resolution context ⇒ %return

Gets the resolution for the context.

See context-set-resolution

context

Passed: a <PangoContext>.

a <PangoContext>, from a pangocairo font map

%return

Returned: a real number.

the resolution in "dots per inch". A negative value will be returned if no resolution has previously been set.

Procedure: context-set-font-options context [options]

Sets the font options used when rendering text with this context.

These options override any options that update_context derives from the target surface.

context

Passed: a <PangoContext>.

a <PangoContext>, from a pangocairo font map

options

Passed, or left out: a <CairoFontOptions>, or #f.

a <CairoFontOptions>, or #f to unset any previously set options. A copy is made.

Procedure: context-set-resolution context dpi

Sets the resolution for the context.

This is a scale factor between points specified in a <PangoFontDescription> and Cairo units. The default value is 96, meaning that a 10 point font will be 13 units high. (10 * 96. / 72. = 13.3).

context

Passed: a <PangoContext>.

a <PangoContext>, from a pangocairo font map

dpi

Passed: a real number.

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.

Procedure: create-context cr ⇒ %return

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 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 cr and do not need to access <PangoContext> directly, you can use create_layout instead.

cr

Passed: a <CairoContext>.

a Cairo context

%return

Returned: a <PangoContext>.

the newly created <PangoContext>

Procedure: create-layout cr ⇒ %return

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 layout:get-size or drawing with functions like show_layout. If you change the transformation or target surface for cr, you need to call update_layout.

This function is the most convenient way to use Cairo with Pango, however it is slightly inefficient since it creates a separate <PangoContext> object for each layout. This might matter in an application that was laying out large amounts of text.

cr

Passed: a <CairoContext>.

a Cairo context

%return

Returned: a <PangoLayout>.

the newly created <PangoLayout>

Procedure: error-underline-path cr x y width 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

Passed: a <CairoContext>.

a Cairo context

x

Passed: a real number.

The X coordinate of one corner of the rectangle

y

Passed: a real number.

The Y coordinate of one corner of the rectangle

width

Passed: a real number.

Non-negative width of the rectangle

height

Passed: a real number.

Non-negative height of the rectangle

Procedure: font-map-get-default ⇒ %return

Gets a default <PangoCairoFontMap> to 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 the <PangoFontMap> and <PangoCairoFontMap> interfaces on the returned object.

The default Cairo fontmap can be changed by using font-map: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.

%return

Returned: a <PangoFontMap>.

the default PangoCairo fontmap for the current thread. This object is owned by Pango and must not be freed.

Procedure: font-map-new ⇒ %return

Creates a new <PangoCairoFontMap> object.

A fontmap is used to cache information about available fonts, and holds certain global parameters such as the resolution. In most cases, you can use func@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 the PangoFontMap‘ and <PangoCairoFontMap> 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.

%return

Returned: a <PangoFontMap>.

the newly allocated <PangoFontMap>, which should be freed with object:unref.

Procedure: font-map-new-for-font-type fonttype ⇒ %return

Creates a new <PangoCairoFontMap> object of the type suitable to be used with cairo font backend of type fonttype.

In most cases one should simply use font-map:new, or in fact in most of those cases, just use font-map:get-default.

fonttype

Passed: a <cairo_font_type_t>, or one of its symbols.

desired <cairo_font_type_t>

%return

Returned: a <PangoFontMap>, or #f.

the newly allocated <PangoFontMap> of suitable type which should be freed with object:unref, or #f if the requested cairo font backend is not supported / compiled in.

Procedure: glyph-string-path cr font 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

Passed: a <CairoContext>.

a Cairo context

font

Passed: a <PangoFont>.

a <PangoFont> from a <PangoCairoFontMap>

glyphs

Passed: a <PangoGlyphString>.

a <PangoGlyphString>

Procedure: layout-line-path cr line

Adds the text in <PangoLayoutLine> to 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

Passed: a <CairoContext>.

a Cairo context

line

Passed: a <PangoLayoutLine>.

a <PangoLayoutLine>

Procedure: layout-path cr layout

Adds the text in a <PangoLayout> to the current path in the specified cairo context.

The top-left corner of the <PangoLayout> will be at the current point of the cairo context.

cr

Passed: a <CairoContext>.

a Cairo context

layout

Passed: a <PangoLayout>.

a Pango layout

Procedure: show-error-underline cr x y width 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

Passed: a <CairoContext>.

a Cairo context

x

Passed: a real number.

The X coordinate of one corner of the rectangle

y

Passed: a real number.

The Y coordinate of one corner of the rectangle

width

Passed: a real number.

Non-negative width of the rectangle

height

Passed: a real number.

Non-negative height of the rectangle

Procedure: show-glyph-item cr text 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 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

Passed: a <CairoContext>.

a Cairo context

text

Passed: a string.

the UTF-8 text that glyph-item refers to

glyph-item

Passed: a <PangoGlyphItem>.

a <PangoGlyphItem>

Procedure: show-glyph-string cr font 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

Passed: a <CairoContext>.

a Cairo context

font

Passed: a <PangoFont>.

a <PangoFont> from a <PangoCairoFontMap>

glyphs

Passed: a <PangoGlyphString>.

a <PangoGlyphString>

Procedure: show-layout cr layout

Draws a <PangoLayout> in the specified cairo context.

The top-left corner of the <PangoLayout> will be drawn at the current point of the cairo context.

cr

Passed: a <CairoContext>.

a Cairo context

layout

Passed: a <PangoLayout>.

a Pango layout

Procedure: show-layout-line cr line

Draws a <PangoLayoutLine> in 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

Passed: a <CairoContext>.

a Cairo context

line

Passed: a <PangoLayoutLine>.

a <PangoLayoutLine>

Procedure: update-context cr context

Updates a <PangoContext> previously 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 layout:context-changed on those layouts.

cr

Passed: a <CairoContext>.

a Cairo context

context

Passed: a <PangoContext>.

a <PangoContext>, from a pangocairo font map

Procedure: update-layout cr layout

Updates the private <PangoContext> of a <PangoLayout> created with create_layout to match the current transformation and target surface of a Cairo context.

cr

Passed: a <CairoContext>.

a Cairo context

layout

Passed: a <PangoLayout>.

a <PangoLayout>, from create_layout