6 Functions

Procedure: attr-allow-breaks-new allow-breaks ⇒ %return

Create a new allow-breaks attribute.

If breaks are disabled, the range will be kept in a single run, as far as possible.

allow-breaks

Passed: a boolean.

#t if we line breaks are allowed

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-background-alpha-new alpha ⇒ %return

Create a new background alpha attribute.

alpha

Passed: an unsigned 16-bit integer.

the alpha value, between 1 and 65536

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-background-new red green blue ⇒ %return

Create a new background color attribute.

red

Passed: an unsigned 16-bit integer.

the red value (ranging from 0 to 65535)

green

Passed: an unsigned 16-bit integer.

the green value

blue

Passed: an unsigned 16-bit integer.

the blue value

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-baseline-shift-new shift ⇒ %return

Create a new baseline displacement attribute.

The effect of this attribute is to shift the baseline of a run, relative to the run of preceding run.

shift

Passed: a 32-bit integer.

either a <PangoBaselineShift> enumeration value or an absolute value (> 1024) in Pango units, relative to the baseline of the previous run. Positive values displace the text upwards.

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-break! text length attr-list offset attrs ⇒ attrs

Apply customization from attributes to the breaks in attrs.

The line breaks are assumed to have been produced by Pango.default_break and Pango.tailor_break.

text

Passed: a string.

text to break. Must be valid UTF-8

length

Passed: a 32-bit integer.

length of text in bytes (may be -1 if text is nul-terminated)

attr-list

Passed: a <PangoAttrList>.

<PangoAttrList> to apply

offset

Passed: a 32-bit integer.

Byte offset of text from the beginning of the paragraph

attrs

Passed: a list or vector, each a <PangoLogAttr>. It is filled in, and returned: a vector, each a <PangoLogAttr>.

array with one <PangoLogAttr> per character in text, plus one extra, to be filled in

attrs-len

Not returned: it is the length of attrs.

length of attrs array

Procedure: attr-fallback-new enable-fallback ⇒ %return

Create a new font fallback attribute.

If fallback is disabled, characters will only be used from the closest matching font on the system. No fallback will be done to other fonts on the system that might contain the characters in the text.

enable-fallback

Passed: a boolean.

#t if we should fall back on other fonts for characters the active font is missing

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-family-new family ⇒ %return

Create a new font family attribute.

family

Passed: a string.

the family or comma-separated list of families

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-font-desc-new desc ⇒ %return

Create a new font description attribute.

This attribute allows setting family, style, weight, variant, stretch, and size simultaneously.

desc

Passed: a <PangoFontDescription>.

the font description

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-font-features-new features ⇒ %return

Create a new font features tag attribute.

You can use this attribute to select OpenType font features like small-caps, alternative glyphs, ligatures, etc. for fonts that support them.

features

Passed: a string.

a string with OpenType font features, with the syntax of the [CSS font-feature-settings property](https://www.w3.org/TR/css-fonts-4/font-rend-desc)

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-font-scale-new scale ⇒ %return

Create a new font scale attribute.

The effect of this attribute is to change the font size of a run, relative to the size of preceding run.

scale

Passed: a <PangoFontScale>, or one of its symbols.

a <PangoFontScale> value, which indicates font size change relative to the size of the previous run.

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-foreground-alpha-new alpha ⇒ %return

Create a new foreground alpha attribute.

alpha

Passed: an unsigned 16-bit integer.

the alpha value, between 1 and 65536

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-foreground-new red green blue ⇒ %return

Create a new foreground color attribute.

red

Passed: an unsigned 16-bit integer.

the red value (ranging from 0 to 65535)

green

Passed: an unsigned 16-bit integer.

the green value

blue

Passed: an unsigned 16-bit integer.

the blue value

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-gravity-hint-new hint ⇒ %return

Create a new gravity hint attribute.

hint

Passed: a <PangoGravityHint>, or one of its symbols.

the gravity hint value

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-gravity-new gravity ⇒ %return

Create a new gravity attribute.

gravity

Passed: a <PangoGravity>, or one of its symbols.

the gravity value; should not be auto

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-insert-hyphens-new insert-hyphens ⇒ %return

Create a new insert-hyphens attribute.

Pango will insert hyphens when breaking lines in the middle of a word. This attribute can be used to suppress the hyphen.

insert-hyphens

Passed: a boolean.

#t if hyphens should be inserted

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-language-new language ⇒ %return

Create a new language tag attribute.

language

Passed: a <PangoLanguage>.

language tag

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-letter-spacing-new letter-spacing ⇒ %return

Create a new letter-spacing attribute.

letter-spacing

Passed: a 32-bit integer.

amount of extra space to add between graphemes of the text, in Pango units

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-line-height-new factor ⇒ %return

Modify the height of logical line extents by a factor.

This affects the values returned by layout-line:get-extents!, layout-line:get-pixel-extents! and layout-iter:get-line-extents!.

factor

Passed: a real number.

the scaling factor to apply to the logical height

%return

Returned: a <PangoAttribute>.

Procedure: attr-line-height-new-absolute height ⇒ %return

Override the height of logical line extents to be height.

This affects the values returned by layout-line:get-extents!, layout-line:get-pixel-extents! and layout-iter:get-line-extents!.

height

Passed: a 32-bit integer.

the line height, in PANGO_SCALE-ths of a point

%return

Returned: a <PangoAttribute>.

Procedure: attr-list-from-string text ⇒ %return

Deserializes a <PangoAttrList> from a string.

This is the counterpart to attr-list:to-string. See that functions for details about the format.

text

Passed: a string.

a string

%return

Returned: a <PangoAttrList>, or #f.

a new <PangoAttrList>

Procedure: attr-overline-color-new red green blue ⇒ %return

Create a new overline color attribute.

This attribute modifies the color of overlines. If not set, overlines will use the foreground color.

red

Passed: an unsigned 16-bit integer.

the red value (ranging from 0 to 65535)

green

Passed: an unsigned 16-bit integer.

the green value

blue

Passed: an unsigned 16-bit integer.

the blue value

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-overline-new overline ⇒ %return

Create a new overline-style attribute.

overline

Passed: a <PangoOverline>, or one of its symbols.

the overline style

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-rise-new rise ⇒ %return

Create a new baseline displacement attribute.

rise

Passed: a 32-bit integer.

the amount that the text should be displaced vertically, in Pango units. Positive values displace the text upwards.

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-scale-new scale-factor ⇒ %return

Create a new font size scale attribute.

The base font for the affected text will have its size multiplied by scale-factor.

scale-factor

Passed: a real number.

factor to scale the font

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-sentence-new ⇒ %return

Marks the range of the attribute as a single sentence.

Note that this may require adjustments to word and sentence classification around the range.

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-shape-new ink-rect logical-rect ⇒ %return

Create a new shape attribute.

A shape is used to impose a particular ink and logical rectangle on the result of shaping a particular glyph. This might be used, for instance, for embedding a picture or a widget inside a <PangoLayout>.

ink-rect

Passed: a <PangoRectangle>.

ink rectangle to assign to each character

logical-rect

Passed: a <PangoRectangle>.

logical rectangle to assign to each character

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-shape-new-with-data ink-rect logical-rect [data] [copy-func] ⇒ %return

Creates a new shape attribute.

Like Pango.AttrShape.new, but a user data pointer is also provided; this pointer can be accessed when later rendering the glyph.

ink-rect

Passed: a <PangoRectangle>.

ink rectangle to assign to each character

logical-rect

Passed: a <PangoRectangle>.

logical rectangle to assign to each character

data

Passed, or left out: a foreign pointer, or a bytevector, or #f.

user data pointer

copy-func

Passed, or left out: a procedure, or #f.

function to copy data when the attribute is copied. If #f, data is simply copied as a pointer

See PangoAttrDataCopyFunc for how it is called.

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

destroy-func

Not passed: guile-gi supplies it.

function to free data when the attribute is freed

See GDestroyNotify for how it is called.

Procedure: attr-show-new flags ⇒ %return

Create a new attribute that influences how invisible characters are rendered.

flags

Passed: a <PangoShowFlags>, or a list of its symbols, or one of them.

<PangoShowFlags> to apply

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-size-new size ⇒ %return

Create a new font-size attribute in fractional points.

size

Passed: a 32-bit integer.

the font size, in PANGO_SCALE-ths of a point

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-size-new-absolute size ⇒ %return

Create a new font-size attribute in device units.

size

Passed: a 32-bit integer.

the font size, in PANGO_SCALE-ths of a device unit

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-stretch-new stretch ⇒ %return

Create a new font stretch attribute.

stretch

Passed: a <PangoStretch>, or one of its symbols.

the stretch

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-strikethrough-color-new red green blue ⇒ %return

Create a new strikethrough color attribute.

This attribute modifies the color of strikethrough lines. If not set, strikethrough lines will use the foreground color.

red

Passed: an unsigned 16-bit integer.

the red value (ranging from 0 to 65535)

green

Passed: an unsigned 16-bit integer.

the green value

blue

Passed: an unsigned 16-bit integer.

the blue value

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-strikethrough-new strikethrough ⇒ %return

Create a new strike-through attribute.

strikethrough

Passed: a boolean.

#t if the text should be struck-through

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-style-new style ⇒ %return

Create a new font slant style attribute.

style

Passed: a <PangoStyle>, or one of its symbols.

the slant style

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-text-transform-new transform ⇒ %return

Create a new attribute that influences how characters are transformed during shaping.

transform

Passed: a <PangoTextTransform>, or one of its symbols.

<PangoTextTransform> to apply

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-type-get-name type ⇒ %return

Fetches the attribute type name.

The attribute type name is the string passed in when registering the type using attr-type:register.

The returned value is an interned string (see intern-string for what that means) that should not be modified or freed.

type

Passed: a <PangoAttrType>, or one of its symbols.

an attribute type ID to fetch the name for

%return

Returned: a string, or #f.

the type ID name (which may be #f), or #f if type is a built-in Pango attribute type or invalid.

Procedure: attr-type-register name ⇒ %return

Allocate a new attribute type ID.

The attribute type name can be accessed later by using attr-type:get-name.

name

Passed: a string.

an identifier for the type

%return

Returned: a <PangoAttrType>.

the new type ID.

Procedure: attr-underline-color-new red green blue ⇒ %return

Create a new underline color attribute.

This attribute modifies the color of underlines. If not set, underlines will use the foreground color.

red

Passed: an unsigned 16-bit integer.

the red value (ranging from 0 to 65535)

green

Passed: an unsigned 16-bit integer.

the green value

blue

Passed: an unsigned 16-bit integer.

the blue value

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-underline-new underline ⇒ %return

Create a new underline-style attribute.

underline

Passed: a <PangoUnderline>, or one of its symbols.

the underline style

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-variant-new variant ⇒ %return

Create a new font variant attribute (normal or small caps).

variant

Passed: a <PangoVariant>, or one of its symbols.

the variant

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy.

Procedure: attr-weight-new weight ⇒ %return

Create a new font weight attribute.

weight

Passed: a <PangoWeight>, or one of its symbols.

the weight

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: attr-word-new ⇒ %return

Marks the range of the attribute as a single word.

Note that this may require adjustments to word and sentence classification around the range.

%return

Returned: a <PangoAttribute>.

the newly allocated <PangoAttribute>, which should be freed with attribute:destroy

Procedure: bidi-type-for-unichar ch ⇒ %return

Determines the bidirectional type of a character.

The bidirectional type is specified in the Unicode Character Database.

A simplified version of this function is available as unichar_direction.

ch

Passed: a character.

a Unicode character

%return

Returned: a <PangoBidiType>.

the bidirectional character type, as used in the Unicode bidirectional algorithm.

Procedure: extents-to-pixels! inclusive nearest ⇒ inclusive nearest

Converts extents from Pango units to device units.

The conversion is done by 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

Passed, and returned: a <PangoRectangle>.

rectangle to round to pixels inclusively

nearest

Passed, and returned: a <PangoRectangle>.

rectangle to round to nearest pixels

Procedure: find-base-dir text length ⇒ %return

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

text

Passed: a string.

the text to process. Must be valid UTF-8

length

Passed: a 32-bit integer.

length of text in bytes (may be -1 if text is nul-terminated)

%return

Returned: a <PangoDirection>.

The direction corresponding to the first strong character. If no such character is found, then neutral is returned.

Procedure: find-paragraph-boundary text length ⇒ paragraph-delimiter-index next-paragraph-start

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 next paragraph (index after all delimiters) is stored n 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

Passed: a string.

UTF-8 text

length

Passed: a 32-bit integer.

length of text in bytes, or -1 if nul-terminated

paragraph-delimiter-index

Returned: a 32-bit integer.

return location for index of delimiter

next-paragraph-start

Returned: a 32-bit integer.

return location for start of next paragraph

Procedure: font-description-from-string str ⇒ %return

Creates a new font description from a string representation.

The string must have the form

[FAMILY-LIST] [STYLE-OPTIONS] [SIZE] [VARIATIONS] [FEATURES]

where FAMILY-LIST is a comma-separated list of families optionally terminated by a comma, STYLE_OPTIONS is a whitespace-separated list of words where each word describes one of style, variant, weight, stretch, or gravity, and SIZE is a decimal number (size in points) or optionally followed by the unit modifier "px" for absolute size.

The following words are understood as styles: "Normal", "Roman", "Oblique", "Italic".

The following words are understood as variants: "Small-Caps", "All-Small-Caps", "Petite-Caps", "All-Petite-Caps", "Unicase", "Title-Caps".

The following words are understood as weights: "Thin", "Ultra-Light", "Extra-Light", "Light", "Semi-Light", "Demi-Light", "Book", "Regular", "Medium", "Semi-Bold", "Demi-Bold", "Bold", "Ultra-Bold", "Extra-Bold", "Heavy", "Black", "Ultra-Black", "Extra-Black".

The following words are understood as stretch values: "Ultra-Condensed", "Extra-Condensed", "Condensed", "Semi-Condensed", "Semi-Expanded", "Expanded", "Extra-Expanded", "Ultra-Expanded".

The following words are understood as gravity values: "Not-Rotated", "South", "Upside-Down", "North", "Rotated-Left", "East", "Rotated-Right", "West".

The following words are understood as color values: "With-Color", "Without-Color".

VARIATIONS is a comma-separated list of font variations of the form @‍axis1=value,axis2=value,...

FEATURES is a comma-separated list of font features of the form \#‍feature1=value,feature2=value,... The =value part can be ommitted if the value is 1.

Any one of the options may be absent. If FAMILY-LIST is absent, then the family_name field of the resulting font description will be initialized to #f. If STYLE-OPTIONS is missing, then all style options will be set to the default values. If SIZE is missing, the size in the resulting font description will be set to 0.

A typical example:

Cantarell Italic Light 15 @‍wght=200 #‍tnum=1

str

Passed: a string.

string representation of a font description.

%return

Returned: a <PangoFontDescription>.

a new <PangoFontDescription>.

Procedure: get-log-attrs! text length level language attrs ⇒ attrs

Computes a <PangoLogAttr> for each character in text.

The attrs array must have one <PangoLogAttr> 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

Passed: a string.

text to process. Must be valid UTF-8

length

Passed: a 32-bit integer.

length in bytes of text

level

Passed: a 32-bit integer.

embedding level, or -1 if unknown

language

Passed: a <PangoLanguage>.

language tag

attrs

Passed: a list or vector, each a <PangoLogAttr>. It is filled in, and returned: a vector, each a <PangoLogAttr>.

array with one <PangoLogAttr> per character in text, plus one extra, to be filled in

attrs-len

Not returned: it is the length of attrs.

length of attrs array

Procedure: gravity-get-for-matrix [matrix] ⇒ %return

Finds the gravity that best matches the rotation component in a <PangoMatrix>.

matrix

Passed, or left out: a <PangoMatrix>, or #f.

a <PangoMatrix>

%return

Returned: a <PangoGravity>.

the gravity of matrix, which will never be auto, or south if matrix is #f

Procedure: gravity-get-for-script script base-gravity hint ⇒ %return

Returns the gravity to use in laying out a <PangoItem>.

The gravity is determined based on the script, base gravity, and hint.

If base-gravity is auto, it is first replaced with the preferred gravity of script. To get the preferred gravity of a script, pass auto and strong in.

script

Passed: a <PangoScript>, or one of its symbols.

<PangoScript> to query

base-gravity

Passed: a <PangoGravity>, or one of its symbols.

base gravity of the paragraph

hint

Passed: a <PangoGravityHint>, or one of its symbols.

orientation hint

%return

Returned: a <PangoGravity>.

resolved gravity suitable to use for a run of text with script

Procedure: gravity-get-for-script-and-width script wide base-gravity hint ⇒ %return

Returns the gravity to use in laying out a single character or <PangoItem>.

The gravity is determined based on the script, East Asian width, base gravity, and hint,

This function is similar to gravity:get-for-script except that this function makes a distinction between narrow/half-width and wide/full-width characters also. Wide/full-width characters always stand upright, that is, they always take the base gravity, whereas narrow/full-width characters are always rotated in vertical context.

If base-gravity is auto, it is first replaced with the preferred gravity of script.

script

Passed: a <PangoScript>, or one of its symbols.

<PangoScript> to query

wide

Passed: a boolean.

#t for wide characters as returned by unichar-iswide?

base-gravity

Passed: a <PangoGravity>, or one of its symbols.

base gravity of the paragraph

hint

Passed: a <PangoGravityHint>, or one of its symbols.

orientation hint

%return

Returned: a <PangoGravity>.

resolved gravity suitable to use for a run of text with script and wide.

Procedure: gravity-to-rotation gravity ⇒ %return

Converts a <PangoGravity> value to its natural rotation in radians.

Note that matrix:rotate takes angle in degrees, not radians. So, to call [method@Pango.Matrix,rotate] with the output of this function you should multiply it by (180. / G_PI).

gravity

Passed: a <PangoGravity>, or one of its symbols.

gravity to query, should not be auto

%return

Returned: a real number.

the rotation value corresponding to gravity.

Procedure: is-zero-width? ch ⇒ %return

Checks if a character that should not be normally rendered.

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 unichar-iszerowidth? and is at best misnamed.

ch

Passed: a character.

a Unicode character

%return

Returned: a boolean.

#t if ch is a zero-width character, #f otherwise

Procedure: itemize context text start-index length attrs [cached-iter] ⇒ %return

Breaks a piece of text into segments with consistent directional level and font.

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

cached-iter should be an iterator over attrs currently positioned at a range before or containing start-index; cached-iter will be advanced to the range covering the position just after start-index + length. (i.e. if itemizing in a loop, just keep passing in the same cached-iter).

context

Passed: a <PangoContext>.

a structure holding information that affects the itemization process.

text

Passed: a string.

the text to itemize. Must be valid UTF-8

start-index

Passed: a 32-bit integer.

first byte in text to process

length

Passed: a 32-bit integer.

the number of bytes (not characters) to process after start-index. This must be >= 0.

attrs

Passed: a <PangoAttrList>.

the set of attributes that apply to text.

cached-iter

Passed, or left out: a <PangoAttrIterator>, or #f.

Cached attribute iterator

%return

Returned: a list, each a <PangoItem>.

a GList of <PangoItem> structures. The items should be freed using item:free in combination with GLib.List.free_full.

Procedure: itemize-with-base-dir context base-dir text start-index length attrs [cached-iter] ⇒ %return

Like itemize, but with an explicitly specified base direction.

The base direction is used when computing bidirectional levels. itemize gets the base direction from the <PangoContext> (see context:set-base-dir).

context

Passed: a <PangoContext>.

a structure holding information that affects the itemization process.

base-dir

Passed: a <PangoDirection>, or one of its symbols.

base direction to use for bidirectional processing

text

Passed: a string.

the text to itemize.

start-index

Passed: a 32-bit integer.

first byte in text to process

length

Passed: a 32-bit integer.

the number of bytes (not characters) to process after start-index. This must be >= 0.

attrs

Passed: a <PangoAttrList>.

the set of attributes that apply to text.

cached-iter

Passed, or left out: a <PangoAttrIterator>, or #f.

Cached attribute iterator

%return

Returned: a list, each a <PangoItem>.

a GList of <PangoItem> structures. The items should be freed using item:free probably in combination with GLib.List.free_full.

Procedure: language-from-string [language] ⇒ %return

Convert a language tag to a <PangoLanguage>.

The language tag must be in a RFC-3066 format. <PangoLanguage> pointers can be efficiently copied (copy the pointer) and compared with other language tags (compare the pointer.)

This function first canonicalizes the string by converting it to lowercase, mapping ’_’ to ’-’, and stripping all characters other than letters and ’-’.

Use language:get-default if you want to get the <PangoLanguage> for the current locale of the process.

language

Passed, or left out: a string, or #f.

a string representing a language tag

%return

Returned: a <PangoLanguage>, or #f.

a <PangoLanguage>

Procedure: language-get-default ⇒ %return

Returns the <PangoLanguage> for the current locale of the process.

On Unix systems, this is the return value is derived from setlocale (LC_CTYPE, NULL), and the user can affect this through the environment variables LC_ALL, LC_CTYPE or LANG (checked in that order). The locale string typically is in the form lang_COUNTRY, where lang is an ISO-639 language code, and COUNTRY is an ISO-3166 country code. For instance, sv_FI for Swedish as written in Finland or pt_BR for Portuguese as written in Brazil.

On Windows, the C library does not use any such environment variables, and setting them won’t affect the behavior of functions like ctime(). The user sets the locale through the Regional Options in the Control Panel. The C library (in the setlocale() function) does not use country and language codes, but country and language names spelled out in English. However, this function does check the above environment variables, and does return a Unix-style locale string based on either said environment variables or the thread’s current locale.

Your application should call setlocale(LC_ALL, "") for the user settings to take effect. GTK does this in its initialization functions automatically (by calling gtk_set_locale()). See the setlocale() manpage for more details.

Note that the default language can change over the life of an application.

Also note that this function will not do the right thing if you use per-thread locales with uselocale(). In that case, you should just call language-from-string yourself.

%return

Returned: a <PangoLanguage>.

the default language as a <PangoLanguage>

Procedure: language-get-preferred ⇒ %return

Returns the list of languages that the user prefers.

The list is specified by the PANGO_LANGUAGE or LANGUAGE environment variables, in order of preference. Note that this list does not necessarily include the language returned by language:get-default.

When choosing language-specific resources, such as the sample text returned by language:get-sample-string, you should first try the default language, followed by the languages returned by this function.

%return

Returned: a vector, each a <PangoLanguage>, or #f.

a #f-terminated array of <PangoLanguage>*

Procedure: layout-deserialize-error-quark ⇒ %return
%return

Returned: an unsigned 32-bit integer.

Procedure: log2vis-get-embedding-levels! text length pbase-dir ⇒ %return pbase-dir

Return the bidirectional embedding levels of the input paragraph.

The bidirectional embedding levels are defined by the [Unicode Bidirectional Algorithm](http://www.unicode.org/reports/tr9/).

If the input base direction is a weak direction, the direction of the characters in the text will determine the final resolved direction.

text

Passed: a string.

the text to itemize.

length

Passed: a 32-bit integer.

the number of bytes (not characters) to process, or -1 if text is nul-terminated and the length should be calculated.

pbase-dir

Passed: a <PangoDirection>, or one of its symbols. Returned: a <PangoDirection>.

input base direction, and output resolved direction.

%return

Returned: a foreign pointer.

a newly allocated array of embedding levels, one item per character (not byte), that should be freed using byte-array:free.

Procedure: markup-parser-finish context ⇒ %return attr-list text accel-char

Finishes parsing markup.

After feeding a Pango markup parser some data with markup-parse-context:parse?, use this function to get the list of attributes and text out of the markup. This function will not free context, use markup-parse-context:free to do so.

context

Passed: a <GMarkupParseContext>.

A valid parse context that was returned from markup_parser_new

%return

Returned: a boolean.

#f if error is set, otherwise #t

attr-list

Returned: a <PangoAttrList>.

address of return location for a <PangoAttrList>

text

Returned: a string.

address of return location for text with tags stripped

accel-char

Returned: a character.

address of return location for accelerator char

Procedure: markup-parser-new accel-marker ⇒ %return

Incrementally parses marked-up text to create a plain-text string and an attribute list.

See the Pango Markup docs for details about the supported markup.

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 low attribute, and the first character so marked will be returned in accel-char, when calling markup_parser_finish. Two accel-marker characters following each other produce a single literal accel-marker character.

To feed markup to the parser, use markup-parse-context:parse? on the returned <GMarkupParseContext>. When done with feeding markup to the parser, use markup_parser_finish to get the data out of it, and then use markup-parse-context:free to free it.

This function is designed for applications that read Pango markup from streams. To simply parse a string containing Pango markup, the parse-markup API is recommended instead.

accel-marker

Passed: a character.

character that precedes an accelerator, or 0 for none

%return

Returned: a <GMarkupParseContext>.

a <GMarkupParseContext> that should be destroyed with markup-parse-context:free.

Procedure: parse-markup markup-text length accel-marker ⇒ %return attr-list text accel-char

Parses marked-up text to create a plain-text string and an attribute list.

See the Pango Markup docs for details about the supported markup.

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

To parse a stream of pango markup incrementally, use markup_parser_new.

If any error happens, none of the output arguments are touched except for error.

markup-text

Passed: a string.

markup to parse (see the Pango Markup docs)

length

Passed: a 32-bit integer.

length of markup-text, or -1 if nul-terminated

accel-marker

Passed: a character.

character that precedes an accelerator, or 0 for none

%return

Returned: a boolean.

#f if error is set, otherwise #t

attr-list

Returned: a <PangoAttrList>.

address of return location for a <PangoAttrList>

text

Returned: a string.

address of return location for text with tags stripped

accel-char

Returned: a character.

address of return location for accelerator char

Procedure: parse-stretch str warn ⇒ %return 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.

str

Passed: a string.

a string to parse.

warn

Passed: a boolean.

if #t, issue a g_warning() on bad input.

%return

Returned: a boolean.

#t if str was successfully parsed.

stretch

Returned: a <PangoStretch>.

a <PangoStretch> to store the result in.

Procedure: parse-style str warn ⇒ %return style

Parses a font style.

The allowed values are "normal", "italic" and "oblique", case variations being ignored.

str

Passed: a string.

a string to parse.

warn

Passed: a boolean.

if #t, issue a g_warning() on bad input.

%return

Returned: a boolean.

#t if str was successfully parsed.

style

Returned: a <PangoStyle>.

a <PangoStyle> to store the result in.

Procedure: parse-variant str warn ⇒ %return variant

Parses a font variant.

The allowed values are "normal", "small-caps", "all-small-caps", "petite-caps", "all-petite-caps", "unicase" and "title-caps", case variations being ignored.

str

Passed: a string.

a string to parse.

warn

Passed: a boolean.

if #t, issue a g_warning() on bad input.

%return

Returned: a boolean.

#t if str was successfully parsed.

variant

Returned: a <PangoVariant>.

a <PangoVariant> to store the result in.

Procedure: parse-weight str warn ⇒ %return weight

Parses a font weight.

The allowed values are "heavy", "ultrabold", "bold", "normal", "light", "ultraleight" and integers. Case variations are ignored.

str

Passed: a string.

a string to parse.

warn

Passed: a boolean.

if #t, issue a g_warning() on bad input.

%return

Returned: a boolean.

#t if str was successfully parsed.

weight

Returned: a <PangoWeight>.

a <PangoWeight> to store the result in.

Procedure: quantize-line-geometry thickness position ⇒ thickness position

Quantizes the thickness and position of a line to whole device pixels.

This is typically used for underline or strikethrough. 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

Passed, and returned: a 32-bit integer.

pointer to the thickness of a line, in Pango units

position

Passed, and returned: a 32-bit integer.

corresponding position

Procedure: reorder-items items ⇒ %return

Reorder items from logical order to visual order.

The visual order is determined from the associated directional levels of the items. The original list is unmodified.

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

items

Passed: a list, each a <PangoItem>.

a GList of <PangoItem> in logical order.

%return

Returned: a list, each a <PangoItem>.

a GList of <PangoItem> structures in visual order.

Procedure: script-get-sample-language script ⇒ %return

Finds a language tag that is reasonably representative of script.

The language will usually be the most widely spoken or used language written in that script: for instance, the sample language for cyrillic is ru (Russian), the sample language for 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 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 language:includes-script?. 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 han when setting context language is not feasible.

script

Passed: a <PangoScript>, or one of its symbols.

a <PangoScript>

%return

Returned: a <PangoLanguage>, or #f.

a <PangoLanguage> that is representative of the script

Procedure: shape-item! item paragraph-text paragraph-length log-attrs glyphs flags ⇒ glyphs

Convert the characters in item into glyphs.

This is similar to Pango.shape_with_flags, except it takes a <PangoItem> instead of separate item-text and analysis arguments.

It also takes log-attrs, which are needed for implementing some aspects of hyphen insertion and text transforms (in particular, capitalization).

Note that the extra attributes in the analyis that is returned from itemize have indices that are relative to the entire paragraph, so you do not pass the full paragraph text as paragraph-text, you need to subtract the item offset from their indices before calling Pango.shape_with_flags.

item

Passed: a <PangoItem>.

<PangoItem> to shape

paragraph-text

Passed: a string, or #f.

text of the paragraph (see details).

paragraph-length

Passed: a 32-bit integer.

the length (in bytes) of paragraph-text. -1 means nul-terminated text.

log-attrs

Passed: a <PangoLogAttr>, or #f.

array of <PangoLogAttr> for item

glyphs

Passed, filled in, and returned: a <PangoGlyphString>.

glyph string in which to store results

flags

Passed: a <PangoShapeFlags>, or a list of its symbols, or one of them.

flags influencing the shaping process

Procedure: tab-array-from-string text ⇒ %return

Deserializes a <PangoTabArray> from a string.

This is the counterpart to tab-array:to-string. See that functions for details about the format.

text

Passed: a string.

a string

%return

Returned: a <PangoTabArray>, or #f.

a new <PangoTabArray>

Procedure: unichar-direction ch ⇒ %return

Determines the inherent direction of a character.

The inherent direction is either ltr, rtl, or 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.BidiType.for_unichar can be used instead.

ch

Passed: a character.

a Unicode character

%return

Returned: a <PangoDirection>.

the direction of the character.

Procedure: units-from-double d ⇒ %return

Converts a floating-point number to Pango units.

The conversion is done by multiplying d by PANGO_SCALE and rounding the result to nearest integer.

d

Passed: a real number.

double floating-point value

%return

Returned: a 32-bit integer.

the value in Pango units.

Procedure: units-to-double i ⇒ %return

Converts a number in Pango units to floating-point.

The conversion is done by dividing i by PANGO_SCALE.

i

Passed: a 32-bit integer.

value in Pango units

%return

Returned: a real number.

the double value.

Procedure: version ⇒ %return

Returns the encoded version of Pango available at run-time.

This is similar to the macro PANGO_VERSION except that the macro returns the encoded version available at compile-time. A version number can be encoded into an integer using PANGO_VERSION_ENCODE().

%return

Returned: a 32-bit integer.

The encoded version of Pango library available at run time.

Procedure: version-check required-major required-minor required-micro ⇒ %return

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.

Compatibility is defined by two things: first the version of the running library is newer than the version required-major.required_minor.required-micro. Second the running library must be binary compatible with the version required-major.required_minor.required-micro (same major version.)

For compile-time version checking use PANGO_VERSION_CHECK().

required-major

Passed: a 32-bit integer.

the required major version

required-minor

Passed: a 32-bit integer.

the required minor version

required-micro

Passed: a 32-bit integer.

the required major version

%return

Returned: a string, or #f.

#f if the Pango library is compatible with the given version, or a string describing the version mismatch. The returned string is owned by Pango and should not be modified or freed.

Procedure: version-string ⇒ %return

Returns the version of Pango available at run-time.

This is similar to the macro PANGO_VERSION_STRING except that the macro returns the version available at compile-time.

%return

Returned: a string.

A string containing the version of Pango library available at run time. The returned string is owned by Pango and should not be modified or freed.