Pango is an [[LGPLv2]] licensed multi-lingual text layout engine written in [[C]].
- [Website](https://www.pango.org/) ([[2025-02-15|currently]] redirects to documentation)
- [Source](https://gitlab.gnome.org/GNOME/pango)
- [Documentation](https://www.gtk.org/docs/architecture/pango)
- [Wikipedia](https://en.wikipedia.org/wiki/Pango)
> Pango is a text (i.e. glyph) layout engine library which works with the [[HarfBuzz]] shaping engine for displaying multi-language text.
# Notability
Recommended by [[GUI - Cairo]] for handling text.
Used by many many applications across many operating systems.
# Philosophy
Used [[HarfBuzz]] and [[FreeType]] to do its job.
## XML
Unfortunately, Pango uses XML for its markup system. Rather it uses a subset of it similar to HTML, in the form of the [[GMarkup]] library. [[GMarkup]] also specifically says to not accept untrusted input, which implies it is insecure. Not ideal.
### Span
The `<span>` tag is the fundamental building block and can host many different attributes:
| Attribute | Info |
| ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **font<br>font_desc** | A font description string, such as “Sans Italic 12”. See [`pango_font_description_from_string()`](https://docs.gtk.org/Pango/type_func.FontDescription.from_string.html) 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. |
| **face<br>font_family** | A font family name. |
| **size<br>font_size** | Font size in 1024ths of a point, or in points (e.g. ‘12.5pt’), or one of the absolute sizes ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’, or a percentage (e.g. ‘200%’), 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’ or size=‘12.5pt’. Support for specifying font sizes in points or as percentages was added in Pango 1.50. |
| **style<br>font_style** | One of ‘normal’, ‘oblique’, ‘italic’. |
| **weight<br>font_weight** | One of ‘ultralight’, ‘light’, ‘normal’, ‘bold’, ‘ultrabold’, ‘heavy’, or a numeric weight. |
| **variant<br>font_variant** | One of ‘normal’, ‘small-caps’, ‘all-small-caps’, ‘petite-caps’, ‘all-petite-caps’, ‘unicase’, ‘title-caps’. Values other than ‘normal’ and ‘small-caps’ are available since 1.50. |
| **stretch<br>font_stretch** | One of ‘ultracondensed’, ‘extracondensed’, ‘condensed’, ‘semicondensed’, ‘normal’, ‘semiexpanded’, ‘expanded’, ‘extraexpanded’, ‘ultraexpanded’. |
| **font_features** | A comma-separated list of OpenType font feature settings, in the same syntax as accepted by CSS. E.g: `font_features='dlig=1, -kern, afrc on'`. |
| **color<br>fgcolor<br>foreground** | An RGB color specification such as ‘#00FF00’ or a color name such as ‘red’. Since 1.38, an RGBA color specification such as ‘#00FF007F’ will be interpreted as specifying both a foreground color and foreground alpha |
| **bgcolor<br>background** | An RGB color specification such as ‘#00FF00’ or a color name such as ‘red’. Since 1.38, an RGBA color specification such as ‘#00FF007F’ will be interpreted as specifying both a background color and background alpha. |
| **alpha<br>fgalpha** | An alpha value for the foreground color, either a plain integer between 1 and 65536 or a percentage value like ‘50%’. |
| **bgalpha<br>background_alpha** | An alpha value for the background color, either a plain integer between 1 and 65536 or a percentage value like ‘50%’. |
| **underline** | One of ‘none’, ‘single’, ‘double’, ‘low’, ‘error’. |
| **underline_color** | The color of underlines; an RGB color specification such as ‘#00FF00’ or a color name such as ‘red’. |
| **overline** | One of ‘none’ or ‘single’. Overline support was added in Pango 1.46. |
| **overline_color** | The color of overlines; an RGB color specification such as ‘#00FF00’ or a color name such as ‘red’. Overline support was added in Pango 1.46. |
| **rise** | Vertical displacement, in Pango units or in points (e.g. ‘5pt’). Can be negative for subscript, positive for superscript. Support for specifying rise in points was added in Pango 1.50. |
| **baseline_shift** | Vertical displacement. In contrast to rise, baseline_shift attributes are cumulative. The value can be a length in Pango units or in points (e.g. ‘5pt’), or ‘superscript’ or ‘subscript’. Available since 1.50. |
| **font_scale** | Font size change. The possible values are ‘superscript’, ‘subscript’ or ‘small-caps’. This is similar to the font_size values ‘smaller’ or ‘larger’, but uses font metrics to find the new size. Available since 1.50. |
| **strikethrough** | ‘true’ or ‘false’ whether to strike through the text. |
| **strikethrough_color** | The color of strikethrough lines; an RGB color specification such as ‘#00FF00’ or a color name such as ‘red’. |
| **fallback** | ‘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. |
| **lang** | A language code, indicating the text language. |
| **letter_spacing** | Inter-letter spacing in 1024ths of a point. |
| **gravity** | One of ‘south’, ‘east’, ‘north’, ‘west’, ‘auto’. |
| **gravity_hint** | One of ‘natural’, ‘strong’, ‘line’. |
| **show** | Specifies what special characters to show visibly. The value can be ‘none’ or a combination of ‘spaces’, ‘line-breaks’ and ‘ignorables’, combined with ‘\|’. Support for showing special characters was added in Pango 1.44. |
| **insert_hyphens** | ‘true’ or ‘false’ to indicate whether hyphens should be inserted when breaking lines in the middle of words. Available since Pango 1.44. |
| **allow_breaks** | ‘true’ or ‘false’ to indicate whether breaking lines is allowed. Available since Pango 1.44. |
| **line_height** | Overrides the line height. The value can be either a factor (< 1024) that is used to scale up the logical extents of runs or an absolute value (in 1024th of a point). Available since Pango 1.50. |
| **text_transform** | Specifies how characters are transformed during shaping. The values can be ‘none’, ‘lowercase’, ‘uppercase’ or ‘capitalize’. Support for text transformation was added in Pango 1.50. |
| **segment** | Overrides word or sentence boundaries. The value can be ‘word’ or ‘sentence’, to indicate that the span should be treated as a single word or sentence. Overlapping segments will be split to allow this, and line breaks will be adjusted accordingly. Available since Pango 1.50. |
## Convenience Tags
| Tag | Usage |
| --------- | -------------------------------------------------------------------- |
| `<b>` | Bold |
| `<big>` | Makes font relatively larger, equivalent to `<span size="larger">` |
| `<i>` | Italic |
| `<s>` | Strikethrough |
| `<sub>` | Subscript |
| `<sup>` | Superscript |
| `<small>` | Makes font relatively smaller, equivalent to `<span size="smaller">` |
| `<tt>` | Monospace font |
| `<u>` | Underline |
# Platform Support
# Features
# Tips
# Resources
## Tutorials
```cardlink
url: https://dthompson.us/posts/font-rendering-in-opengl-with-pango-and-cairo.html
title: "Font Rendering in OpenGL with Pango and Cairo — dthompson"
host: dthompson.us
```
# References