Crate pango[][src]

Expand description

Rust Pango bindings

This library contains safe Rust bindings for Pango. It is a part of gtk-rs.

Pango 1.38 is the lowest supported version for the underlying library.

Re-exports

pub use ffi;
pub use glib;
pub use crate::analysis::Analysis;
pub use crate::attr_class::AttrClass;
pub use crate::language::Language;
pub use crate::layout::HitPosition;
pub use crate::rectangle::Rectangle;
pub use glyph::GlyphGeometry;
pub use glyph::GlyphInfo;

Modules

analysis
attr_class
attr_iterator
attr_list
attribute
functions
glyph
item
language
layout
prelude

Traits and essential types inteded for blanket imports.

rectangle

Structs

AttrIterator

The AttrIterator structure is used to represent an iterator through a AttrList. A new iterator is created with AttrList::iterator(). Once the iterator is created, it can be advanced through the style changes in the text using next(). At each style change, the range of the current style segment and the attributes currently in effect can be queried.

AttrList

The AttrList structure represents a list of attributes that apply to a section of text. The attributes are, in general, allowed to overlap in an arbitrary fashion, however, if the attributes are manipulated only through change(), the overlap between properties will meet stricter criteria.

Attribute

The Attribute structure represents the common portions of all attributes. Particular types of attributes include this structure as their initial portion. The common portion of the attribute holds the range to which the value in the type-specific part of the attribute applies and should be initialized using init(). By default an attribute will have an all-inclusive range of [0,G_MAXUINT].

Color

The Color structure is used to represent a color in an uncalibrated RGB color-space.

Context

The Context structure stores global information used to control the itemization process.

Coverage

The Coverage structure represents a map from Unicode characters to CoverageLevel. It is an opaque structure with no public fields.

Font

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

FontDescription

The FontDescription structure represents the description of an ideal font. These structures are used both to list what fonts are available on the system and also for specifying the characteristics of a font to load.

FontFace

The FontFace structure is used to represent a group of fonts with the same family, slant, weight, width, but varying sizes.

FontFamily

The FontFamily structure is used to represent a family of related font faces. The faces in a family share a common design, but differ in slant, weight, width and other aspects.

FontMap

The FontMap represents the set of fonts available for a particular rendering system. This is a virtual object with implementations being specific to particular rendering systems. To create an implementation of a FontMap, the rendering-system specific code should allocate a larger structure that contains a nested FontMap, fill in the <structfield>klass</structfield> member of the nested FontMap with a pointer to a appropriate PangoFontMapClass, then call pango_font_map_init() on the structure.

FontMask

The bits in a FontMask correspond to fields in a FontDescription that have been set.

FontMetrics

A FontMetrics structure holds the overall metric information for a font (possibly restricted to a script). The fields of this structure are private to implementations of a font backend. See the documentation of the corresponding getters for documentation of their meaning.

Fontset

A Fontset represents a set of Font to use when rendering text. It is the result of resolving a FontDescription against a particular Context. It has operations for finding the component font for a particular Unicode character, and for finding a composite set of metrics for the entire fontset.

FontsetSimple

FontsetSimple is a implementation of the abstract Fontset base class in terms of an array of fonts, which the creator provides when constructing the FontsetSimple.

GlyphItem

A GlyphItem is a pair of a Item and the glyphs resulting from shaping the text corresponding to an item. As an example of the usage of GlyphItem, the results of shaping text with Layout is a list of LayoutLine, each of which contains a list of GlyphItem.

GlyphItemIter

A GlyphItemIter is an iterator over the clusters in a GlyphItem. The <firstterm>forward direction</firstterm> of the iterator is the logical direction of text. That is, with increasing start_index and start_char values. If glyph_item is right-to-left (that is, if <literal>``glyph_item->item->analysis.level</literal> is odd), then start_glyph decreases as the iterator moves forward. Moreover, in right-to-left cases, start_glyph is greater than end_glyph.

GlyphString

The GlyphString structure is used to store strings of glyphs with geometry and visual attribute information. The storage for the glyph information is owned by the structure which simplifies memory management.

Item

The Item structure stores information about a segment of text.

Layout

The Layout structure represents an entire paragraph of text. It is initialized with a Context, UTF-8 string and set of attributes for that string. Once that is done, the set of formatted lines can be extracted from the object, the layout can be rendered, and conversion between logical character positions within the layout’s text, and the physical position of the resulting glyphs can be made.

LayoutIter

A LayoutIter structure can be used to iterate over the visual extents of a Layout.

LayoutLine

The LayoutLine structure represents one of the lines resulting from laying out a paragraph via Layout. LayoutLine structures are obtained by calling Layout::line() and are only valid until the text, attributes, or settings of the parent Layout are modified.

Matrix

A structure specifying a transformation between user-space coordinates and device coordinates. The transformation is given by

Renderer

Renderer is a base class for objects that are used to render Pango objects such as GlyphString and Layout.

ShapeFlags

Flags influencing the shaping process. These can be passed to pango_shape_with_flags().

ShowFlags

These flags affect how Pango treats characters that are normally not visible in the output.

TabArray

A TabArray struct contains an array of tab stops. Each tab stop has an alignment and a position.

Enums

Alignment

A Alignment describes how to align the lines of a Layout within the available space. If the Layout is set to justify using Layout::set_justify(), this only has effect for partial lines.

AttrType

The AttrType distinguishes between different types of attributes. Along with the predefined values, it is possible to allocate additional values for custom attributes using pango_attr_type_register(). The predefined values are given below. The type of structure used to store the attribute is listed in parentheses after the description.

BidiType

The BidiType type represents the bidirectional character type of a Unicode character as specified by the Unicode bidirectional algorithm</ulink>.

CoverageLevel

Used to indicate how well a font can represent a particular Unicode character point for a particular script.

Direction

The Direction type represents a direction in the Unicode bidirectional algorithm; not every value in this enumeration makes sense for every usage of Direction; for example, the return value of unichar_direction() and find_base_dir() cannot be WeakLtr or WeakRtl, since every character is either neutral or has a strong direction; on the other hand Neutral doesn’t make sense to pass to itemize_with_base_dir().

EllipsizeMode

The EllipsizeMode type describes what sort of (if any) ellipsization should be applied to a line of text. In the ellipsization process characters are removed from the text in order to make it fit to a given width and replaced with an ellipsis.

Gravity

The Gravity type represents the orientation of glyphs in a segment of text. This is useful when rendering vertical text layouts. In those situations, the layout is rotated using a non-identity PangoMatrix, and then glyph orientation is controlled using Gravity. Not every value in this enumeration makes sense for every usage of Gravity; for example, Auto only can be passed to Context::set_base_gravity() and can only be returned by Context::base_gravity().

GravityHint

The GravityHint defines how horizontal scripts should behave in a vertical context. That is, English excerpt in a vertical paragraph for example.

Overlinev1_46

The Overline enumeration is used to specify whether text should be overlined, and if so, the type of line.

RenderPart

RenderPart defines different items to render for such purposes as setting colors.

Script

The Script enumeration identifies different writing systems. The values correspond to the names as defined in the Unicode standard. See Unicode Standard Annex 24: Script names</ulink>.

Stretch

An enumeration specifying the width of the font relative to other designs within a family.

Style

An enumeration specifying the various slant styles possible for a font.

TabAlign

A TabAlign specifies where a tab stop appears relative to the text.

Underline

The Underline enumeration is used to specify whether text should be underlined, and if so, the type of underlining.

Variant

An enumeration specifying capitalization variant of the font.

Weight

An enumeration specifying the weight (boldness) of a font. This is a numerical value ranging from 100 to 1000, but there are some predefined values:

WrapMode

A WrapMode describes how to wrap the lines of a Layout to the desired width.

Constants

NONE_FONT
NONE_FONTSET
NONE_FONT_FACE
NONE_FONT_FAMILY
NONE_FONT_MAP
NONE_RENDERER
SCALE
SCALE_LARGE

The scale factor for one magnification step (1.2).

SCALE_MEDIUM

The scale factor for normal size (1.0).

SCALE_SMALL

The scale factor for one shrinking step (1 / 1.2).

SCALE_XX_LARGE

The scale factor for three magnification steps (1.2 * 1.2 * 1.2).

SCALE_XX_SMALL

The scale factor for three shrinking steps (1 / (1.2 * 1.2 * 1.2)).

SCALE_X_LARGE

The scale factor for two magnification steps (1.2 * 1.2).

SCALE_X_SMALL

The scale factor for two shrinking steps (1 / (1.2 * 1.2)).

Functions

extents_to_pixels

Converts extents from Pango units to device units, dividing by the PANGO_SCALE factor and performing rounding.

find_base_dir

Searches a string the first character that has a strong direction, according to the Unicode bidirectional algorithm.

find_paragraph_boundary

Locates a paragraph boundary in text. A boundary is caused by delimiter characters, such as a newline, carriage return, carriage return-newline pair, or Unicode paragraph separator character. The index of the run of delimiters is returned in paragraph_delimiter_index. The index of the start of the paragraph (index after all delimiters) is stored in next_paragraph_start.

is_zero_width

Checks ch to see if it is a character that should not be normally rendered on the screen. This includes all Unicode characters with “ZERO WIDTH” in their name, as well as <firstterm>bidi</firstterm> formatting characters, and a few other ones. This is totally different from g_unichar_iszerowidth() and is at best misnamed.

itemize

Breaks a piece of text into segments with consistent directional level and shaping engine. Each byte of text will be contained in exactly one of the items in the returned list; the generated list of items will be in logical order (the start offsets of the items are ascending).

itemize_with_base_dir

Like itemize(), but the base direction to use when computing bidirectional levels (see pango_context_set_base_dir ()), is specified explicitly rather than gotten from the Context.

parse_markup

Parses marked-up text (see

parse_stretch

Parses a font stretch. The allowed values are “ultra_condensed”, “extra_condensed”, “condensed”, “semi_condensed”, “normal”, “semi_expanded”, “expanded”, “extra_expanded” and “ultra_expanded”. Case variations are ignored and the ‘_’ characters may be omitted.

parse_style

Parses a font style. The allowed values are “normal”, “italic” and “oblique”, case variations being ignored.

parse_variant

Parses a font variant. The allowed values are “normal” and “smallcaps” or “small_caps”, case variations being ignored.

parse_weight

Parses a font weight. The allowed values are “heavy”, “ultrabold”, “bold”, “normal”, “light”, “ultraleight” and integers. Case variations are ignored.

quantize_line_geometry

Quantizes the thickness and position of a line, typically an underline or strikethrough, to whole device pixels, that is integer multiples of PANGO_SCALE. The purpose of this function is to avoid such lines looking blurry.

reorder_items

From a list of items in logical order and the associated directional levels, produce a list in visual order. The original list is unmodified.

shape

Given a segment of text and the corresponding Analysis structure returned from itemize(), convert the characters into glyphs. You may also pass in only a substring of the item from itemize().

shape_full

Given a segment of text and the corresponding Analysis structure returned from itemize(), convert the characters into glyphs. You may also pass in only a substring of the item from itemize().

shape_with_flagsv1_44

Given a segment of text and the corresponding Analysis structure returned from itemize(), convert the characters into glyphs. You may also pass in only a substring of the item from itemize().

unichar_direction

Determines the inherent direction of a character; either Direction::Ltr, Direction::Rtl, or Direction::Neutral.

units_from_double

Converts a floating-point number to Pango units: multiplies it by PANGO_SCALE and rounds to nearest integer.

units_to_double

Converts a number in Pango units to floating-point: divides it by PANGO_SCALE.

version

This is similar to the macro PANGO_VERSION except that it returns the encoded version of Pango available at run-time, as opposed to the version available at compile-time.

version_check

Checks that the Pango library in use is compatible with the given version. Generally you would pass in the constants PANGO_VERSION_MAJOR, PANGO_VERSION_MINOR, PANGO_VERSION_MICRO as the three arguments to this function; that produces a check that the library in use at run-time is compatible with the version of Pango the application or module was compiled against.

version_string

This is similar to the macro PANGO_VERSION_STRING except that it returns the version of Pango available at run-time, as opposed to the version available at compile-time.

Type Definitions

Glyph
GlyphUnit
LayoutRun