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.


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;



Traits and essential types inteded for blanket imports.




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.


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.


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


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


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


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


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.


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.


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


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.


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.


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


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.


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 is a implementation of the abstract Fontset base class in terms of an array of fonts, which the creator provides when constructing the FontsetSimple.


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.


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.


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.


The Item structure stores information about a segment of text.


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.


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


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.


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


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


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


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


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



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.


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.


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


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


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


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.


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


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


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


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


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


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


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


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


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


An enumeration specifying capitalization variant of the font.


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:


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



The scale factor for one magnification step (1.2).


The scale factor for normal size (1.0).


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


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


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


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


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



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


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


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.


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.


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


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.


Parses marked-up text (see


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.


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


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


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


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.


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


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


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


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


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


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


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


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.


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.


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