Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

Pango

Module Functions

Pango.break(text, analysis)
Determines possible line, word, and character breaks for a string of Unicode text.
Pango.get_log_attrs(text, level, language)
Computes a Pango::LogAttr for each character in text. The return value(Pango::LogAttrs array must have one Pango::LogAttr for each position in text; if text contains N characters, it has N+1 positions, including the last position at the end of the text. text should be an entire paragraph; logical attributes can't be computed without context (for example you need to see spaces on either side of a word to know the word is a word).
Pango.find_paragraph_boundary(text)
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. If no delimiters are found, both paragraph_delimiter_index and next_paragraph_start are filled with the length of text (an index one off the end).
  • text: UTF-8 text
  • Returns: [paragraph_delimiter_index, next_paragraph_start]:
    • paragraph_delimiter_index : index of delimiter
    • next_paragraph_start: start of next paragraph
Pango.shape(text, analysis)
Given a segment of text and the corresponding Pango::Analysis returned from Pango::Context#itemize, convert the characters into glyphs. You may also pass in only a substring of the item from Pango::Context#itemize.
Pango.parse_markup(markup_text, accel_marker = nil)
Parses marked-up text (see markup format) to create a plaintext string and an attribute list. If accel_marker is non-nil, the given character will mark the character following it as an accelerator. For example, the accel marker might be an ampersand or underscore. All characters marked as an accelerator will receive a Pango::UNDERLINE_LOW attribute, and the first character so marked will be returned in accel_char. Two accel_marker characters following each other produce a single literal accel_marker character. Raises GLib::Error if fails to parse markup_text.
  • markup_text: markup to parse (see markup format)
  • accel_marker: a character code(Integer) that precedes an accelerator, or nil for none
  • Returns: [attr_list, text, accel_char]
    • attr_list: a Pango::AttrList, or nil
    • text: a text with tags stripped, or nil
    • accel_char: an accelerator char, or nil
Pango.reorder_items(logial_items)
From an Array of items in logical order and the associated directional levels, produce a list in visual order. The original list is unmodified.
Pango.unichar_direction(ch)
Determines the direction of a character; either Pango::DIRECTION_LTR, Pango::DIRECTION_RTL, or Pango::DIRECTION_NEUTRAL. Since 1.4
  • ch: character to examine(Integer)
  • Returns: the direction of a character, as used in the Unicode bidirectional algorithm. (PangoDirection)
Pango.find_base_dir(text)
Searches a string the first character that has a strong direction, according to the Unicode bidirectional algorithm.
  • text: the text to process
  • Returns: The direction corresponding to the first strong character. If no such character is found, then Pango::DIRECTION_NEUTRAL is returned.
Pango.pixels(d)
Converts a dimension to device units.
  • d: a dimension in Pango units.
  • Returns: a converted device units.
Pango.cairo_available?
Returns true if Ruby/Cairo is supported.
  • Returns true if Ruby/Cairo is supported.

Constants

Alignment

An Alignment describes how to align the lines of a Pango::Layout within the available space. If the Pango::Layout is set to justify using Pango::layout#justify=?, then this only has an effect for partial lines.

ALIGN_LEFT
Put all available space on the right
ALIGN_CENTER
Center the line within the available space
ALIGN_RIGHT
Put all available space on the left

CoverageLevel

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

COVERAGE_NONE
The character is not representable with the font.
COVERAGE_FALLBACK
The character is represented in a way that may be comprehensible but is not the correct graphical form. For instance, a Hangul character represented as a a sequence of Jamos, or a Latin transliteration of a Cyrillic word.
COVERAGE_APPROXIMATE
The character is represented as basically the correct graphical form, but with a stylistic variant inappropriate for the current script.
COVERAGE_EXACT
The character is represented as the correct graphical form.

Direction

The Direction type represents a direction in the Unicode bidirectional algorithm; not every value in this enumeration makes sense for every usage of PangoDirection; for example, the return value of Pango.unichar_direction and Pango.find_base_dir cannot be Pango::DIRECTION_WEAK_LTR or Pango::DIRECTION_WEAK_RTL, since every character is either neutral or has a strong direction.

The Pango::DIRECTION_TTB_LTR, Pango::DIRECTION_TTB_RTL values come from an earlier interpretation of this enumeration as the writing direction of a block of text and are no longer used; See the Text module of the CSS3 spec for how vertical text is planned to be handled in a future version of Pango. The explanation of why Pango::DIRECTION_TTB_LTR is treated as Pango::DIRECTION_RTL can be found there as well.

DIRECTION_LTR
A strong left-to-right direction
DIRECTION_RTL
A strong right-to-left direction
DIRECTION_TTB_LTR
Deprecated value; treated the same as Pango::DIRECTION_RTL
DIRECTION_TTB_RTL
Deprecated value; treated the same as Pango::DIRECTION_LTR
DIRECTION_WEAK_LTR
A weak left-to-right direction
DIRECTION_WEAK_RTL
A weak right-to-left direction
DIRECTION_NEUTRAL
No direction specified

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.

ELLIPSIZE_NONE
No ellipsization
ELLIPSIZE_START
Omit characters at the start of the text
ELLIPSIZE_MIDDLE
Omit characters in the middle of the text
ELLIPSIZE_END
Omit characters at the end of the text

FontMask

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

FONT_MASK_FAMILY
the font family is specified.
FONT_MASK_STYLE
the font style is specified.
FONT_MASK_VARIANT
the font variant is specified.
FONT_MASK_WEIGHT
the font weight is specified.
FONT_MASK_STRETCH
the font stretch is specified.
FONT_MASK_SIZE
the font size is specified.

RenderPart

PangoRenderPart defines different items to render for such purposes as setting colors. Since 2.8

PART_FOREGROUND
the text itself
PART_BACKGROUND
the area behind the text
PART_UNDERLINE
underlines
PART_STRIKETHROUGH
strikethrough lines

AttrScale

SCALE_XX_SMALL
The scale factor for three shrinking steps (1 / (1.2 * 1.2 * 1.2)).
SCALE_X_SMALL
The scale factor for two shrinking steps (1 / (1.2 * 1.2)).
SCALE_SMALL
The scale factor for one shrinking step (1 / 1.2).
SCALE_MEDIUM
The scale factor for normal size (1.0).
SCALE_LARGE
The scale factor for one magnification step (1.2).
SCALE_X_LARGE
The scale factor for two magnification steps (1.2 * 1.2).
SCALE_XX_LARGE
The scale factor for three magnification steps (1.2 * 1.2 * 1.2).

Stretch

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

STRETCH_ULTRA_CONDENSED
STRETCH_EXTRA_CONDENSED
STRETCH_CONDENSED
STRETCH_SEMI_CONDENSED
STRETCH_NORMAL
the normal width
STRETCH_SEMI_EXPANDED
STRETCH_EXPANDED
STRETCH_EXTRA_EXPANDED
STRETCH_ULTRA_EXPANDED

Style

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

STYLE_NORMAL
the font is upright.
STYLE_OBLIQUE
the font is slanted, but in a roman style.
STYLE_ITALIC
the font is slanted in an italic style.

TabAlign

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

TAB_LEFT
the tab stop appears to the left of the text.

Underline

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

UNDERLINE_NONE
no underline should be drawn.
UNDERLINE_SINGLE
a single underline should be drawn.
UNDERLINE_DOUBLE
a double underline should be drawn.
UNDERLINE_LOW
a single underline should be drawn at a position beneath the ink extents of the text being underlined. This should be used only for underlining single characters, such as for keyboard accelerators. Pango::UNDERLINE_SINGLE should be used for extended portions of text.
UNDERLINE_ERROR
a wavy underline should be drawn below. This underline is typically used to indicate an error such as a possilble mispelling; in some cases an contrasting color may automatically be used. Pango 1.4

WrapMode

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

WRAP_WORD
wrap lines at word boundaries.
WRAP_CHAR
wrap lines at character boundaries.
WRAP_WORD_CHAR
wrap lines at word boundaries, but fall back to character boundaries if there is not enough space for a full word.

Script

The Script enumeration identifies different writing systems. The values correspond to the names defined in the Unicode standard. (See Unicode Standard Annex 24: Script names).

INVALID_CODE
a value never used for any unicode character
COMMON
a character used by multiple different scripts
INHERITED
a mark glyph that takes its script from the base glyph to which it is attached.
ARABIC
ARMENIAN
BENGALI
BOPOMOFO
BRAILLE
BUHID
CANADIAN_ABORIGINAL
CHEROKEE
COPTIC
CYPRIOT
CYRILLIC
DESERET
DEVANAGARI
ETHIOPIC
GEORGIAN
GOTHIC
GREEK
GUJARATI
GURMUKHI
HAN
HANGUL
HANUNOO
HEBREW
HIRAGANA
KANNADA
KATAKANA
KHMER
LAO
LATIN
LIMBU
LINEAR_B
MALAYALAM
MONGOLIAN
MYANMAR
Matrix
OGHAM
OLD_ITALIC
ORIYA
OSMANYA
RUNIC
SHAVIAN
SINHALA
SYRIAC
TAGALOG
TAGBANWA
TAI_LE
TAMIL
TELUGU
THAANA
THAI
TIBETAN
UGARITIC
YI

Variant

An enumeration specifying capitalization variant of the font.

VARIANT_NORMAL
A normal font.
VARIANT_SMALL_CAPS
A font with the lower case characters replaced by smaller variants of the capital characters.

Weight

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

WEIGHT_ULTRALIGHT
the ultralight weight (= 200)
WEIGHT_LIGHT
the light weight (=300)
WEIGHT_NORMAL
the default weight (= 400)
WEIGHT_SEMIBOLD
a weight intermediate between normal and bold (=600)
WEIGHT_BOLD
the bold weight (= 700)
WEIGHT_ULTRABOLD
the ultrabold weight (= 800)
WEIGHT_HEAVY
the heavy weight (= 900)

Misc

SCALE
The Pango::SCALE represents the scale between dimensions used for Pango distances and device units. (The definition of device units is dependent on the output device; it will typically be pixels for a screen, and points for a printer.) Pango::SCALE is currently 1024, but this may be changed in the future. When setting font sizes, device units are always considered to be points (as in "12 point font"), rather than pixels.
LOG_DOMAIN
Error log domain.
BUILD_VERSION
Compiled pango version [major, minor, micro]
FONT_MASK_GRAVITY
SCRIPT_ARABIC
SCRIPT_ARMENIAN
SCRIPT_BALINESE
SCRIPT_BENGALI
SCRIPT_BOPOMOFO
SCRIPT_BRAILLE
SCRIPT_BUGINESE
SCRIPT_BUHID
SCRIPT_CANADIAN_ABORIGINAL
SCRIPT_CHEROKEE
SCRIPT_COMMON
SCRIPT_COPTIC
SCRIPT_CUNEIFORM
SCRIPT_CYPRIOT
SCRIPT_CYRILLIC
SCRIPT_DESERET
SCRIPT_DEVANAGARI
SCRIPT_ETHIOPIC
SCRIPT_GEORGIAN
SCRIPT_GLAGOLITIC
SCRIPT_GOTHIC
SCRIPT_GREEK
SCRIPT_GUJARATI
SCRIPT_GURMUKHI
SCRIPT_HAN
SCRIPT_HANGUL
SCRIPT_HANUNOO
SCRIPT_HEBREW
SCRIPT_HIRAGANA
SCRIPT_INHERITED
SCRIPT_INVALID_CODE
SCRIPT_KANNADA
SCRIP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