pangocairo

package
v0.0.0-...-aefa52a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2024 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

GType values.

Functions

func ContextGetFontOptions

func ContextGetFontOptions(context *pango.Context) *cairo.FontOptions

ContextGetFontOptions retrieves any font rendering options previously set with pangocairo.ContextSetFontOptions().

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

The function takes the following parameters:

  • context: PangoContext, from a pangocairo font map.

The function returns the following values:

  • fontOptions (optional): font options previously set on the context, or NULL if no options have been set. This value is owned by the context and must not be modified or freed.

func ContextGetResolution

func ContextGetResolution(context *pango.Context) float64

ContextGetResolution gets the resolution for the context. See pangocairo.ContextSetResolution().

The function takes the following parameters:

  • context: PangoContext, from a pangocairo font map.

The function returns the following values:

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

func ContextSetFontOptions

func ContextSetFontOptions(context *pango.Context, options *cairo.FontOptions)

ContextSetFontOptions sets the font options used when rendering text with this context.

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

The function takes the following parameters:

  • context: PangoContext, from a pangocairo font map.
  • options (optional): cairo_font_options_t, or NULL to unset any previously set options. A copy is made.

func ContextSetResolution

func ContextSetResolution(context *pango.Context, dpi float64)

ContextSetResolution 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).

The function takes the following parameters:

  • context: PangoContext, from a pangocairo font map.
  • dpi: 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.

func ContextSetShapeRenderer

func ContextSetShapeRenderer(context *pango.Context, fn ShapeRendererFunc)

ContextSetShapeRenderer sets callback function for context to use for rendering attributes of type PANGO_ATTR_SHAPE.

See PangoCairoShapeRendererFunc for details.

The function takes the following parameters:

  • context: PangoContext, from a pangocairo font map.
  • fn (optional): callback function for rendering attributes of type PANGO_ATTR_SHAPE, or NULL to disable shape rendering.

func CreateContext

func CreateContext(cr *cairo.Context) *pango.Context

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

The function takes the following parameters:

  • cr: cairo context.

The function returns the following values:

  • context: newly created PangoContext. Free with g_object_unref().

func CreateLayout

func CreateLayout(cr *cairo.Context) *pango.Layout

CreateLayout 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 pango.Layout.GetSize() 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.

The function takes the following parameters:

  • cr: cairo context.

The function returns the following values:

  • layout: newly created PangoLayout. Free with g_object_unref().

func ErrorUnderlinePath

func ErrorUnderlinePath(cr *cairo.Context, x, y, width, height float64)

ErrorUnderlinePath: 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.

The function takes the following parameters:

  • cr: cairo context.
  • x: x coordinate of one corner of the rectangle.
  • y: y coordinate of one corner of the rectangle.
  • width: non-negative width of the rectangle.
  • height: non-negative height of the rectangle.

func FontMapGetDefault

func FontMapGetDefault() pango.FontMapper

FontMapGetDefault 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 pangocairo.FontMap.SetDefault(). 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.

The function returns the following values:

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

func GlyphStringPath

func GlyphStringPath(cr *cairo.Context, font pango.Fonter, glyphs *pango.GlyphString)

GlyphStringPath 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.

The function takes the following parameters:

  • cr: cairo context.
  • font: PangoFont from a PangoCairoFontMap.
  • glyphs: PangoGlyphString.

func LayoutLinePath

func LayoutLinePath(cr *cairo.Context, line *pango.LayoutLine)

LayoutLinePath 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.

The function takes the following parameters:

  • cr: cairo context.
  • line: PangoLayoutLine.

func LayoutPath

func LayoutPath(cr *cairo.Context, layout *pango.Layout)

LayoutPath 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.

The function takes the following parameters:

  • cr: cairo context.
  • layout: pango layout.

func NewFontMap

func NewFontMap() pango.FontMapper

NewFontMap 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 `funcPangoCairo.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.

The function returns the following values:

  • fontMap: newly allocated PangoFontMap, which should be freed with g_object_unref().

func ShowErrorUnderline

func ShowErrorUnderline(cr *cairo.Context, x, y, width, height float64)

ShowErrorUnderline: 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.

The function takes the following parameters:

  • cr: cairo context.
  • x: x coordinate of one corner of the rectangle.
  • y: y coordinate of one corner of the rectangle.
  • width: non-negative width of the rectangle.
  • height: non-negative height of the rectangle.

func ShowGlyphItem

func ShowGlyphItem(cr *cairo.Context, text string, glyphItem *pango.GlyphItem)

ShowGlyphItem 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.

The function takes the following parameters:

  • cr: cairo context.
  • text: UTF-8 text that glyph_item refers to.
  • glyphItem: PangoGlyphItem.

func ShowGlyphString

func ShowGlyphString(cr *cairo.Context, font pango.Fonter, glyphs *pango.GlyphString)

ShowGlyphString 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.

The function takes the following parameters:

  • cr: cairo context.
  • font: PangoFont from a PangoCairoFontMap.
  • glyphs: PangoGlyphString.

func ShowLayout

func ShowLayout(cr *cairo.Context, layout *pango.Layout)

ShowLayout 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.

The function takes the following parameters:

  • cr: cairo context.
  • layout: pango layout.

func ShowLayoutLine

func ShowLayoutLine(cr *cairo.Context, line *pango.LayoutLine)

ShowLayoutLine 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.

The function takes the following parameters:

  • cr: cairo context.
  • line: PangoLayoutLine.

func UpdateContext

func UpdateContext(cr *cairo.Context, context *pango.Context)

UpdateContext 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 pango.Layout.ContextChanged() on those layouts.

The function takes the following parameters:

  • cr: cairo context.
  • context: PangoContext, from a pangocairo font map.

func UpdateLayout

func UpdateLayout(cr *cairo.Context, layout *pango.Layout)

UpdateLayout updates the private PangoContext of a PangoLayout created with create_layout to match the current transformation and target surface of a Cairo context.

The function takes the following parameters:

  • cr: cairo context.
  • layout: PangoLayout, from create_layout.

Types

type Font

type Font struct {
	pango.Font
	// contains filtered or unexported fields
}

Font: PangoCairoFont is an interface exported by fonts for use with Cairo.

The actual type of the font will depend on the particular font technology Cairo was compiled to use.

Font wraps an interface. This means the user can get the underlying type by calling Cast().

func BaseFont

func BaseFont(obj Fonter) *Font

BaseFont returns the underlying base object.

type FontMap

type FontMap struct {
	pango.FontMap
	// contains filtered or unexported fields
}

FontMap: PangoCairoFontMap is an interface exported by font maps for use with Cairo.

The actual type of the font map will depend on the particular font technology Cairo was compiled to use.

FontMap wraps an interface. This means the user can get the underlying type by calling Cast().

func (*FontMap) Resolution

func (fontmap *FontMap) Resolution() float64

Resolution gets the resolution for the fontmap.

See pangocairo.FontMap.SetResolution().

The function returns the following values:

  • gdouble: resolution in "dots per inch".

func (*FontMap) SetDefault

func (fontmap *FontMap) SetDefault()

SetDefault sets a default PangoCairoFontMap to use with Cairo.

This can be used to change the Cairo font backend that the default fontmap uses for example. The old default font map is unreffed and the new font map referenced.

Note that since Pango 1.32.6, the default fontmap is per-thread. This function only changes the default fontmap for the current thread. Default fontmaps of existing threads are not changed. Default fontmaps of any new threads will still be created using pangocairo.FontMap.New.

A value of NULL for fontmap will cause the current default font map to be released and a new default font map to be created on demand, using pangocairo.FontMap.New.

func (*FontMap) SetResolution

func (fontmap *FontMap) SetResolution(dpi float64)

SetResolution sets the resolution for the fontmap.

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).

The function takes the following parameters:

  • dpi: resolution in "dots per inch". (Physical inches aren't actually involved; the terminology is conventional.).

type FontMapper

type FontMapper interface {
	coreglib.Objector
}

FontMapper describes FontMap's interface methods.

type Fonter

type Fonter interface {
	coreglib.Objector
	// contains filtered or unexported methods
}

Fonter describes Font's interface methods.

type ShapeRendererFunc

type ShapeRendererFunc func(cr *cairo.Context, attr *pango.AttrShape, doPath bool)

ShapeRendererFunc: function type for rendering attributes of type PANGO_ATTR_SHAPE with Pango's Cairo renderer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL