Text Attribute Markup

Text Attribute Markup — Simple markup language to encode text with attributes

Pango Text Attribute Markup Language

Frequently, you want to display some text to the user with attributes applied to part of the text (for example, you might want bold or italicized words). With the base Pango interfaces, you could create a PangoAttrList and apply it to the text; the problem is that you'd need to apply attributes to some numeric range of characters, for example "characters 12-17." This is broken from an internationalization standpoint; once the text is translated, the word you wanted to italicize could be in a different position.

The solution is to include the text attributes in the string to be translated. Pango provides this feature with a small markup language. You can parse a marked-up string into the string text plus a PangoAttrList using the function pango_parse_markup().

A simple example of a marked-up string might be: "<span foreground="blue" size="x-large">Blue text</span> is <i>cool</i>!"

The root tag of a marked-up document is <markup>, but pango_parse_markup() allows you to omit this tag, so you will most likely never need to use it. The most general markup tag is <span>, then there are some convenience tags. <span> has the following attributes:

<span> attributes

font[1], font_desc

A font description string, such as "Sans Italic 12". See pango_font_description_from_string() for a description of the format of the string representation . Note that any other span attributes will override this description. So if you have "Sans Italic" and also a style="normal" attribute, you will get Sans normal, not italic.

font_family, face

A font family name

font_size[1], size

Font size in 1024ths of a point, or one of the absolute sizes 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', or one of the relative sizes 'smaller' or 'larger'. If you want to specify a absolute size, it's usually easier to take advantage of the ability to specify a partial font description using 'font'; you can use font='12.5' rather than size='12800'.

font_style[1], style

One of 'normal', 'oblique', 'italic'

font_weight[1], weight

One of 'ultralight', 'light', 'normal', 'bold', 'ultrabold', 'heavy', or a numeric weight

font_variant[1], variant

One of 'normal' or 'smallcaps'

font_stretch[1], stretch

One of 'ultracondensed', 'extracondensed', 'condensed', 'semicondensed', 'normal', 'semiexpanded', 'expanded', 'extraexpanded', 'ultraexpanded'

foreground, fgcolor[1], color

An RGB color specification such as '#00FF00' or a color name such as 'red'

background, bgcolor[1]

An RGB color specification such as '#00FF00' or a color name such as 'red'


One of 'none', 'single', 'double', 'low', 'error'


The color of underlines; an RGB color specification such as '#00FF00' or a color name such as 'red'


Vertical displacement, in 10000ths of an em. Can be negative for subscript, positive for superscript.


'true' or 'false' whether to strike through the text


The color of strikethrough lines; an RGB color specification such as '#00FF00' or a color name such as 'red'


'true' or 'false' whether to enable fallback. If disabled, then 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. Fallback is enabled by default. Most applications should not disable fallback.


A language code, indicating the text language


Inter-letter spacing in 1024ths of a point.


One of 'south', 'east', 'north', 'west', 'auto'.


One of 'natural', 'strong', 'line'.

The following convenience tags are provided:

Convenience tags




Makes font relatively larger, equivalent to <span size="larger">










Makes font relatively smaller, equivalent to <span size="smaller">


Monospace font



[1] Since 1.21