Libraries:Gtk:Pango:Global
Functions
BidiTypeForUnichar(ch @ Std.Integer.SmallT) : Gtk.Pango.BidiType.T
ExtentsToPixels(inclusive @ Gtk.Pango.Rectangle.T, nearest @ Gtk.Pango.Rectangle.T) : Std.Object.T
Converts extents from Pango units to device units, dividing by the PANGO_SCALE factor and performing rounding.
The inclusive rectangle is converted by flooring the x/y coordinates and extending width/height, such that the final rectangle completely includes the original rectangle.
The nearest rectangle is converted by rounding the coordinates of the rectangle to the nearest device unit (pixel).
The rule to which argument to use is: if you want the resulting device-space rectangle to completely contain the original rectangle, pass it in as inclusive. If you want two touching-but-not-overlapping rectangles stay touching-but-not-overlapping after rounding to device units, pass them in as nearest.
inclusive | rectangle to round to pixels inclusively, or NULL. [allow-none] |
nearest | rectangle to round to nearest pixels, or NULL. [allow-none] |
FindBaseDir(text @ Std.String.T, length @ Std.Integer.SmallT) : Gtk.Pango.Direction.T
Searches a string the first character that has a strong direction, according to the Unicode bidirectional algorithm.
text | the text to process |
length | length of text in bytes (may be -1 if text is nul-terminated) |
Returns | The direction corresponding to the first strong character. If no such character is found, then Gtk.Pango.Direction.Neutral is returned. |
FindParagraphBoundary(text @ Std.String.T, length @ Std.Integer.SmallT, paragraph_delimiter_index @ Std.Object.T, next_paragraph_start @ Std.Object.T) : Std.Object.T
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 |
length | length of text in bytes, or -1 if nul-terminated |
paragraph_delimiter_index | return location for index of delimiter |
next_paragraph_start | return location for start of next paragraph |
GetLogAttrs(text @ Std.String.T, length @ Std.Integer.SmallT, level @ Std.Integer.SmallT, language @ Gtk.Pango.Language.T, log_attrs @ Gtk.Pango.LogAttr.T, attrs_len @ Std.Integer.SmallT) : Std.Object.T
Computes a Gtk.Pango.LogAttr.T for each character in text. The log_attrs array must have one Gtk.Pango.LogAttr.T 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).
text | text to process |
length | length in bytes of text |
level | embedding level, or -1 if unknown |
language | language tag |
log_attrs | array with one Gtk.Pango.LogAttr.T per character in text, plus one extra, to be filled in |
attrs_len | length of log_attrs array |
GetMirrorChar(ch @ Std.Integer.SmallT, mirrored_ch @ Std.Object.T) : Std.Symbol.T
GravityGetForMatrix(matrix @ Gtk.Pango.Matrix.T) : Gtk.Pango.Gravity.T
Finds the gravity that best matches the rotation component in a Gtk.Pango.Matrix.T.
matrix | a Gtk.Pango.Matrix.T |
Returns | the gravity of matrix, which will never be Gtk.Pango.Gravity.Auto, or Gtk.Pango.Gravity.South if matrix is NULL |
GravityGetForScript(script @ Gtk.Pango.Script.T, base_gravity @ Gtk.Pango.Gravity.T, hint @ Gtk.Pango.GravityHint.T) : Gtk.Pango.Gravity.T
Based on the script, base gravity, and hint, returns actual gravity to use in laying out a single Gtk.Pango.Item.T.
If base_gravity is Gtk.Pango.Gravity.Auto, it is first replaced with the preferred gravity of script. To get the preferred gravity of a script, pass Gtk.Pango.Gravity.Auto and Gtk.Pango.GravityHint.Strong in.
script | Gtk.Pango.Script.T to query |
base_gravity | base gravity of the paragraph |
hint | orientation hint |
Returns | resolved gravity suitable to use for a run of text with script. |
GravityGetForScriptAndWidth(script @ Gtk.Pango.Script.T, wide @ Std.Symbol.T, base_gravity @ Gtk.Pango.Gravity.T, hint @ Gtk.Pango.GravityHint.T) : Gtk.Pango.Gravity.T
Based on the script, East Asian width, base gravity, and hint, returns actual gravity to use in laying out a single character or Gtk.Pango.Item.T.
This function is similar to GravityGetForScript except that this function makes a distinction between narrow/half-width and wide/full-width characters also. Wide/full-width characters always stand <emph>upright</emph>, that is, they always take the base gravity, whereas narrow/full-width characters are always rotated in vertical context.
If base_gravity is Gtk.Pango.Gravity.Auto, it is first replaced with the preferred gravity of script.
script | Gtk.Pango.Script.T to query |
wide | TRUE for wide characters as returned by Gtk.Glib.GUnicode.UnicharIswide |
base_gravity | base gravity of the paragraph |
hint | orientation hint |
Returns | resolved gravity suitable to use for a run of text with script and wide. |
GravityToRotation(gravity @ Gtk.Pango.Gravity.T) : Std.Real.T
Converts a Gtk.Pango.Gravity.T value to its natural rotation in radians. gravity should not be Gtk.Pango.Gravity.Auto.
Note that Gtk.Pango.Matrix.Rotate takes angle in degrees, not radians. So, to call Gtk.Pango.Matrix.Rotate with the output of this function you should multiply it by (180. / G_PI).
gravity | gravity to query |
Returns | the rotation value corresponding to gravity. |
IsZeroWidth(ch @ Std.Integer.SmallT) : Std.Symbol.T
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 bidi formatting characters, and a few other ones. This is totally different from Gtk.Glib.GUnicode.UnicharIszerowidth and is at best misnamed.
ItemizeWithBaseDir(context @ Gtk.Pango.Context.T, base_dir @ Gtk.Pango.Direction.T, text @ Std.String.T, start_index @ Std.Integer.SmallT, length @ Std.Integer.SmallT, attrs @ Gtk.Pango.AttrList.T, cached_iter @ Gtk.Pango.AttrIterator.T) : Std.Object.T
Like pango_itemize(), but the base direction to use when computing bidirectional levels (see Gtk.Pango.Context.SetBaseDir), is specified explicitly rather than gotten from the Gtk.Pango.Context.T.
context | a structure holding information that affects the itemization process. |
base_dir | base direction to use for bidirectional processing |
text | the text to itemize. |
start_index | first byte in text to process |
length | the number of bytes (not characters) to process after start_index. This must be >= 0. |
attrs | the set of attributes that apply to text. |
cached_iter | Cached attribute iterator, or NULL. [allow-none] |
Returns | a GList of Gtk.Pango.Item.T structures. The items should be freed using Gtk.Pango.Item.Free probably in combination with g_list_foreach(), and the list itself using g_list_free(). [transfer full][element-type Pango.Item] |
ParseEnum(type @ Gtk.GObject.Type.T, str @ Std.String.T, value @ Std.Object.T, warn @ Std.Symbol.T, possible_values @ Std.Object.T) : Std.Symbol.T
Parses an enum type and stores the result in value.
If str does not match the nick name of any of the possible values for the enum and is not an integer, FALSE is returned, a warning is issued if warn is TRUE, and a string representing the list of possible values is stored in possible_values. The list is slash-separated, eg. "none/start/middle/end". If failed and possible_values is not NULL, returned string should be freed using g_free().
type | enum type to parse, eg. PANGO_TYPE_ELLIPSIZE_MODE. |
str | string to parse. May be NULL. [allow-none] |
value | integer to store the result in, or NULL. [out][allow-none] |
warn | if TRUE, issue a g_warning() on bad input. |
possible_values | place to store list of possible values on failure, or NULL. [out][allow-none] |
Returns | TRUE if str was successfully parsed. |
ParseMarkup(markup_text @ Std.String.T, length @ Std.Integer.SmallT, accel_marker @ Std.Integer.SmallT, attr_list @ Std.Object.T, text @ Std.Object.T, accel_char @ Std.Object.T, error @ Std.Object.T) : Std.Symbol.T
Parses marked-up text (see markup format) to create a plain-text string and an attribute list.
If accel_marker is nonzero, the given character will mark the character following it as an accelerator. For example, accel_marker might be an ampersand or underscore. All characters marked as an accelerator will receive a Gtk.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.
If any error happens, none of the output arguments are touched except for error.
markup_text | markup to parse (see markup format) |
length | length of markup_text, or -1 if nul-terminated |
accel_marker | character that precedes an accelerator, or 0 for none |
attr_list | address of return location for a Gtk.Pango.AttrList.T, or NULL. [out][allow-none] |
text | address of return location for text with tags stripped, or NULL. [out][allow-none] |
accel_char | address of return location for accelerator char, or NULL. [out][allow-none] |
error | address of return location for errors, or NULL |
Returns | FALSE if error is set, otherwise TRUE |
ParseStretch(str @ Std.String.T, stretch @ Std.Object.T, warn @ Std.Symbol.T) : Std.Symbol.T
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.
str | a string to parse. |
stretch | a Gtk.Pango.Stretch.T to store the result in. |
warn | if TRUE, issue a g_warning() on bad input. |
Returns | TRUE if str was successfully parsed. |
ParseStyle(str @ Std.String.T, style @ Std.Object.T, warn @ Std.Symbol.T) : Std.Symbol.T
Parses a font style. The allowed values are "normal", "italic" and "oblique", case variations being ignored.
str | a string to parse. |
style | a Gtk.Pango.Style.T to store the result in. |
warn | if TRUE, issue a g_warning() on bad input. |
Returns | TRUE if str was successfully parsed. |
ParseVariant(str @ Std.String.T, variant @ Std.Object.T, warn @ Std.Symbol.T) : Std.Symbol.T
Parses a font variant. The allowed values are "normal" and "smallcaps" or "small_caps", case variations being ignored.
str | a string to parse. |
variant | a Gtk.Pango.Variant.T to store the result in. |
warn | if TRUE, issue a g_warning() on bad input. |
Returns | TRUE if str was successfully parsed. |
ParseWeight(str @ Std.String.T, weight @ Std.Object.T, warn @ Std.Symbol.T) : Std.Symbol.T
Parses a font weight. The allowed values are "heavy", "ultrabold", "bold", "normal", "light", "ultraleight" and integers. Case variations are ignored.
str | a string to parse. |
weight | a Gtk.Pango.Weight.T to store the result in. |
warn | if TRUE, issue a g_warning() on bad input. |
Returns | TRUE if str was successfully parsed. |
QuantizeLineGeometry(thickness @ Std.Object.T, position @ Std.Object.T) : Std.Object.T
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.
Care is taken to make sure thickness is at least one pixel when this function returns, but returned position may become zero as a result of rounding.
thickness | pointer to the thickness of a line, in Pango units. [inout] |
position | corresponding position. [inout] |
ReadLine(stream @ Std.Object.T, str @ Gtk.Glib.GString.T) : Std.Integer.SmallT
Reads an entire line from a file into a buffer. Lines may be delimited with '\n', '\r', '\n\r', or '\r\n'. The delimiter is not written into the buffer. Text after a '#' character is treated as a comment and skipped. '\' can be used to escape a # character. '\' proceeding a line delimiter combines adjacent lines. A '\' proceeding any other character is ignored and written into the output buffer unmodified.
stream | a stdio stream |
str | Gtk.Glib.GString.T buffer into which to write the result. [out] |
Returns | 0 if the stream was already at an EOF character, otherwise the number of lines read (this is useful for maintaining a line number counter which doesn't combine lines with '\') |
ReorderItems(logical_items @ Std.Object.T) : Std.Object.T
From a list of items in logical order and the associated directional levels, produce a list in visual order. The original list is unmodified.
logical_items | a GList of Gtk.Pango.Item.T in logical order. |
Returns | a GList of Gtk.Pango.Item.T structures in visual order. (Please open a bug if you use this function. It is not a particularly convenient interface, and the code is duplicated elsewhere in Pango for that reason.). [transfer full][element-type Pango.Item] |
ScanInt(pos @ Std.Object.T, out @ Std.Object.T) : Std.Symbol.T
Scans an integer. Leading white space is skipped.
pos | in/out string position. [inout] |
out | an int into which to write the result. [out] |
Returns | FALSE if a parse error occurred. |
ScanString(pos @ Std.Object.T, out @ Gtk.Glib.GString.T) : Std.Symbol.T
Scans a string into a Gtk.Glib.GString.T buffer. The string may either be a sequence of non-white-space characters, or a quoted string with '"'. Instead a quoted string, '\"' represents a literal quote. Leading white space outside of quotes is skipped.
pos | in/out string position. [inout] |
out | a Gtk.Glib.GString.T into which to write the result. [out] |
Returns | FALSE if a parse error occurred. |
ScanWord(pos @ Std.Object.T, out @ Gtk.Glib.GString.T) : Std.Symbol.T
Scans a word into a Gtk.Glib.GString.T buffer. A word consists of [A-Za-z_] followed by zero or more [A-Za-z_0-9] Leading white space is skipped.
pos | in/out string position. [inout] |
out | a Gtk.Glib.GString.T into which to write the result. [out] |
Returns | FALSE if a parse error occurred. |
ScriptForUnichar(ch @ Std.Integer.SmallT) : Gtk.Pango.Script.T
Looks up the Gtk.Pango.Script.T for a particular character (as defined by Unicode Standard Annex 24). No check is made for ch being a valid Unicode character; if you pass in invalid character, the result is undefined.
As of Pango 1.18, this function simply returns the return value of Gtk.Glib.GUnicode.UnicharGetScript.
ch | a Unicode character |
Returns | the Gtk.Pango.Script.T for the character. |
ScriptGetSampleLanguage(script @ Gtk.Pango.Script.T) : Gtk.Pango.Language.T
Given a script, finds a language tag that is reasonably representative of that script. This will usually be the most widely spoken or used language written in that script: for instance, the sample language for Gtk.Pango.Script.Cyrillic is ru (Russian), the sample language for Gtk.Pango.Script.Arabic is ar.
For some scripts, no sample language will be returned because there is no language that is sufficiently representative. The best example of this is Gtk.Pango.Script.Han, where various different variants of written Chinese, Japanese, and Korean all use significantly different sets of Han characters and forms of shared characters. No sample language can be provided for many historical scripts as well.
As of 1.18, this function checks the environment variables PANGO_LANGUAGE and LANGUAGE (checked in that order) first. If one of them is set, it is parsed as a list of language tags separated by colons or other separators. This function will return the first language in the parsed list that Pango believes may use script for writing. This last predicate is tested using Gtk.Pango.Language.IncludesScript. This can be used to control Pango's font selection for non-primary languages. For example, a PANGO_LANGUAGE enviroment variable set to "en:fa" makes Pango choose fonts suitable for Persian (fa) instead of Arabic (ar) when a segment of Arabic text is found in an otherwise non-Arabic text. The same trick can be used to choose a default language for Gtk.Pango.Script.Han when setting context language is not feasible.
script | a Gtk.Pango.Script.T |
Returns | a Gtk.Pango.Language.T that is representative of the script, or NULL if no such language exists. |
SkipSpace(pos @ Std.Object.T) : Std.Symbol.T
Skips 0 or more characters of white space.
pos | in/out string position. [inout] |
Returns | FALSE if skipping the white space leaves the position at a '\0' character. |
SplitFileList(str @ Std.String.T) : Std.Object.T
Splits a G_SEARCHPATH_SEPARATOR-separated list of files, stripping white space and substituting ~/ with $HOME/.
str | a G_SEARCHPATH_SEPARATOR separated list of filenames |
Returns | a list of strings to be freed with Gtk.Glib.GStrfuncs.Strfreev. [transfer full][array zero-terminated=1] |
TrimString(str @ Std.String.T) : Std.String.T
Trims leading and trailing whitespace from a string.
str | a string |
Returns | A newly-allocated string that must be freed with g_free() |
UnicharDirection(ch @ Std.Integer.SmallT) : Gtk.Pango.Direction.T
Determines the inherent direction of a character; either Gtk.Pango.Direction.Ltr, Gtk.Pango.Direction.Rtl, or Gtk.Pango.Direction.Neutral.
This function is useful to categorize characters into left-to-right letters, right-to-left letters, and everything else. If full Unicode bidirectional type of a character is needed, pango_bidi_type_for_gunichar() can be used instead.
ch | a Unicode character |
Returns | the direction of the character. |
Determines the normative bidirectional character type of a character, as specified in the Unicode Character Database.
A simplified version of this function is available as pango_unichar_get_direction().