1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>Text Attribute Markup</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="Pango Reference Manual">
8 <link rel="up" href="pango.html" title="Basic Pango Interfaces">
9 <link rel="prev" href="pango-Tab-Stops.html" title="Tab Stops">
10 <link rel="next" href="pango-Layout-Objects.html" title="Layout Objects">
11 <meta name="generator" content="GTK-Doc V1.18.1 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
16 <td><a accesskey="p" href="pango-Tab-Stops.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
17 <td><a accesskey="u" href="pango.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
18 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
19 <th width="100%" align="center">Pango Reference Manual</th>
20 <td><a accesskey="n" href="pango-Layout-Objects.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
22 <div class="refentry">
23 <a name="PangoMarkupFormat"></a><div class="titlepage"></div>
24 <div class="refnamediv"><table width="100%"><tr>
26 <h2><span class="refentrytitle">Text Attribute Markup</span></h2>
27 <p>Text Attribute Markup — Simple
28 markup language to encode text with attributes</p>
30 <td valign="top" align="right"></td>
32 <div class="refsect1">
33 <a name="PangoMarkupFormatLanguage"></a><h2>Pango Text Attribute Markup Language</h2>
35 Frequently, you want to display some text to the user with attributes
36 applied to part of the text (for example, you might want bold or
37 italicized words). With the base Pango interfaces, you could create a
38 <a class="link" href="pango-Text-Attributes.html#PangoAttrList">PangoAttrList</a> and apply it to the
39 text; the problem is that you'd need to apply attributes to some
40 numeric range of characters, for example "characters 12-17." This is
41 broken from an internationalization standpoint; once the text is
42 translated, the word you wanted to italicize could be in a different
46 The solution is to include the text attributes in the string to be
47 translated. Pango provides this feature with a small markup language.
48 You can parse a marked-up string into the string text plus a
49 <a class="link" href="pango-Text-Attributes.html#PangoAttrList">PangoAttrList</a> using the function
50 <a class="link" href="pango-Text-Attributes.html#pango-parse-markup" title="pango_parse_markup ()">pango_parse_markup()</a>.
53 A simple example of a marked-up string might be:
54 <code class="literal">"<span foreground="blue" size="x-large">Blue text</span> is <i>cool</i>!"</code>
57 Pango uses #GMarkup to parse this language, which means that XML features
58 such as numeric character entities such as &#169; for © can
62 The root tag of a marked-up document is <markup>, but <a class="link" href="pango-Text-Attributes.html#pango-parse-markup" title="pango_parse_markup ()">pango_parse_markup()</a> allows you to
63 omit this tag, so you will most likely never need to use it. The most
64 general markup tag is <span>, then there are some convenience
65 tags. <span> has the following attributes:
67 <div class="variablelist">
68 <p class="title"><b><span> attributes</b></p>
70 <col align="left" valign="top">
73 <td><p><span class="term">font<sup>[<a name="since_1_21" href="#ftn.since_1_21" class="footnote">1</a>]</sup>, </span><span class="term">font_desc</span></p></td>
75 A font description string, such as "Sans Italic 12". See
76 <a class="link" href="pango-Fonts.html#pango-font-description-from-string" title="pango_font_description_from_string ()">pango_font_description_from_string()</a>
77 for a description of the format of the string representation . Note that any
78 other span attributes will override this description. So if you have
79 "Sans Italic" and also a style="normal" attribute, you will get Sans normal,
83 <td><p><span class="term">font_family, </span><span class="term">face</span></p></td>
89 <td><p><span class="term">font_size<sup>[<a href="PangoMarkupFormat.html#ftn.since_1_21" class="footnoteref">1</a>]</sup>, </span><span class="term">size</span></p></td>
91 Font size in 1024ths of a point, or one of the absolute sizes
92 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large',
93 'xx-large', or one of the relative sizes 'smaller' or 'larger'.
94 If you want to specify a absolute size, it's usually easier
95 to take advantage of the ability to specify a partial
96 font description using 'font'; you can use
97 <code class="literal">font='12.5'</code> rather than
98 <code class="literal">size='12800'</code>.
102 <td><p><span class="term">font_style<sup>[<a href="PangoMarkupFormat.html#ftn.since_1_21" class="footnoteref">1</a>]</sup>, </span><span class="term">style</span></p></td>
104 One of 'normal', 'oblique', 'italic'
108 <td><p><span class="term">font_weight<sup>[<a href="PangoMarkupFormat.html#ftn.since_1_21" class="footnoteref">1</a>]</sup>, </span><span class="term">weight</span></p></td>
110 One of 'ultralight', 'light', 'normal', 'bold', 'ultrabold', 'heavy',
115 <td><p><span class="term">font_variant<sup>[<a href="PangoMarkupFormat.html#ftn.since_1_21" class="footnoteref">1</a>]</sup>, </span><span class="term">variant</span></p></td>
117 One of 'normal' or 'smallcaps'
121 <td><p><span class="term">font_stretch<sup>[<a href="PangoMarkupFormat.html#ftn.since_1_21" class="footnoteref">1</a>]</sup>, </span><span class="term">stretch</span></p></td>
123 One of 'ultracondensed', 'extracondensed', 'condensed',
124 'semicondensed', 'normal', 'semiexpanded', 'expanded',
125 'extraexpanded', 'ultraexpanded'
129 <td><p><span class="term">foreground, </span><span class="term">fgcolor<sup>[<a href="PangoMarkupFormat.html#ftn.since_1_21" class="footnoteref">1</a>]</sup>, </span><span class="term">color</span></p></td>
131 An RGB color specification such as '#00FF00' or a color name such as
136 <td><p><span class="term">background, </span><span class="term">bgcolor<sup>[<a href="PangoMarkupFormat.html#ftn.since_1_21" class="footnoteref">1</a>]</sup></span></p></td>
138 An RGB color specification such as '#00FF00' or a color name such as
143 <td><p><span class="term">underline</span></p></td>
145 One of 'none', 'single', 'double', 'low', 'error'
149 <td><p><span class="term">underline_color</span></p></td>
151 The color of underlines; an RGB color specification such as '#00FF00'
152 or a color name such as 'red'
156 <td><p><span class="term">rise</span></p></td>
158 Vertical displacement, in 10000ths of an em. Can be negative for
159 subscript, positive for superscript.
163 <td><p><span class="term">strikethrough</span></p></td>
165 'true' or 'false' whether to strike through the text
169 <td><p><span class="term">strikethrough_color</span></p></td>
171 The color of strikethrough lines; an RGB color specification such as
172 '#00FF00' or a color name such as 'red'
176 <td><p><span class="term">fallback</span></p></td>
178 'true' or 'false' whether to enable fallback. If disabled, then characters
179 will only be used from the closest matching font on the system. No fallback
180 will be done to other fonts on the system that might contain the characters
181 in the text. Fallback is enabled by default. Most applications should not
186 <td><p><span class="term">lang</span></p></td>
188 A language code, indicating the text language
192 <td><p><span class="term">letter_spacing</span></p></td>
194 Inter-letter spacing in 1024ths of a point.
198 <td><p><span class="term">gravity</span></p></td>
200 One of 'south', 'east', 'north', 'west', 'auto'.
204 <td><p><span class="term">gravity_hint</span></p></td>
206 One of 'natural', 'strong', 'line'.
216 The following convenience tags are provided:
219 <div class="variablelist">
220 <p class="title"><b>Convenience tags</b></p>
222 <col align="left" valign="top">
225 <td><p><span class="term">b</span></p></td>
231 <td><p><span class="term">big</span></p></td>
233 Makes font relatively larger, equivalent to <span size="larger">
237 <td><p><span class="term">i</span></p></td>
243 <td><p><span class="term">s</span></p></td>
249 <td><p><span class="term">sub</span></p></td>
255 <td><p><span class="term">sup</span></p></td>
261 <td><p><span class="term">small</span></p></td>
263 Makes font relatively smaller, equivalent to <span size="smaller">
267 <td><p><span class="term">tt</span></p></td>
273 <td><p><span class="term">u</span></p></td>
285 <div class="footnotes">
286 <br><hr width="100" align="left">
287 <div class="footnote"><p><sup>[<a id="ftn.since_1_21" href="#since_1_21" class="para">1</a>] </sup>Since 1.21</p></div>
292 Generated by GTK-Doc V1.18.1</div>