The Pango Markup Language

The Pango Markup Language — a simple markup language for encoding attributes with text.

Description

The pango markup language is a very simple SGML-like language that allows you specify attributes with the text they are applied to by using a small set of markup tags. A simple example of a string using markup is:

<span foreground="blue" size="100">Blue text</span> is <i>cool</i>!

Using the pango markup language to markup text and parsing the result with the pango.parse_markup() function is a convenient way to generate the pango.AttrList and plain text that can be used in a pango.Layout.

The root tag of a marked-up document is <markup>, but the pango.parse_markup() function allows you to omit this tag, so you will most likely never need to use it. The most general markup tag is <span>. The <span> tag has the following attributes:

font_descA font description string, such as "Sans Italic 12"; 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_familyA font family name such as "normal", "sans", "serif" or "monospace".
faceA synonym for font_family
sizeThe font size in thousandths 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'.
styleThe slant style - one of 'normal', 'oblique', or 'italic'
weightThe font weight - one of 'ultralight', 'light', 'normal', 'bold', 'ultrabold', 'heavy', or a numeric weight.
variantThe font variant - either 'normal' or 'smallcaps'.
stretchThe font width - one of 'ultracondensed', 'extracondensed', 'condensed', 'semicondensed', 'normal', 'semiexpanded', 'expanded', 'extraexpanded', 'ultraexpanded'.
foregroundAn RGB color specification such as '#00FF00' or a color name such as 'red'.
backgroundAn RGB color specification such as '#00FF00' or a color name such as 'red'.
underlineThe underline style - one of 'single', 'double', 'low', or 'none'.
riseThe vertical displacement from the baseline, in ten thousandths of an em. Can be negative for subscript, positive for superscript.
strikethrough'true' or 'false' whether to strike through the text.
fallbackIf TRUE enable fallback to other fonts of characters are missing from the current font. 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.
langA language code, indicating the text language.

There are a number of convenience tags that encapsulate specific span options:

bMake the text bold.
bigMakes font relatively larger, equivalent to <span size="larger">.
iMake the text italic.
sStrikethrough the text.
subSubscript the text.
supSuperscript the text.
smallMakes font relatively smaller, equivalent to <span size="smaller">.
ttUse a monospace font.
uUnderline the text.