1 <refentry id="PangoMarkupFormat" revision="11 Dec 2002">
3 <refentrytitle>Text Attribute Markup</refentrytitle>
4 <manvolnum>3</manvolnum>
5 <refmiscinfo>Pango Library</refmiscinfo>
9 <refname>Text Attribute Markup</refname><refpurpose>Simple
10 markup language to encode text with attributes</refpurpose>
13 <refsect1 id="PangoMarkupFormatLanguage">
14 <title>Pango Text Attribute Markup Language</title>
17 Frequently, you want to display some text to the user with attributes
18 applied to part of the text (for example, you might want bold or
19 italicized words). With the base Pango interfaces, you could create a
20 <link linkend="PangoAttrList">PangoAttrList</link> and apply it to the
21 text; the problem is that you'd need to apply attributes to some
22 numeric range of characters, for example "characters 12-17." This is
23 broken from an internationalization standpoint; once the text is
24 translated, the word you wanted to italicize could be in a different
29 The solution is to include the text attributes in the string to be
30 translated. Pango provides this feature with a small markup language.
31 You can parse a marked-up string into the string text plus a
32 <link linkend="PangoAttrList">PangoAttrList</link> using the function
33 <link linkend="pango-parse-markup">pango_parse_markup()</link>.
37 A simple example of a marked-up string might be:
38 <literal>"<span foreground="blue" size="x-large">Blue text</span> is <i>cool</i>!"</literal>
42 Pango uses #GMarkup to parse this language, which means that XML features
43 such as numeric character entities such as &#169; for © can
48 The root tag of a marked-up document is <markup>, but <link
49 linkend="pango-parse-markup">pango_parse_markup()</link> allows you to
50 omit this tag, so you will most likely never need to use it. The most
51 general markup tag is <span>, then there are some convenience
52 tags. <span> has the following attributes:
53 <variablelist><title><span> attributes</title>
56 <term>font<footnote id='since_1_21'><para>Since 1.21</para></footnote></term>
57 <term>font_desc</term>
59 A font description string, such as "Sans Italic 12". See
60 <link linkend="pango-font-description-from-string">pango_font_description_from_string()</link>
61 for a description of the format of the string representation . Note that any
62 other span attributes will override this description. So if you have
63 "Sans Italic" and also a style="normal" attribute, you will get Sans normal,
64 not italic.</para></listitem>
68 <term>font_family</term>
76 <term>font_size<footnoteref linkend='since_1_21'/></term>
79 Font size in 1024ths of a point, or one of the absolute sizes
80 'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large',
81 'xx-large', or one of the relative sizes 'smaller' or 'larger'.
82 If you want to specify a absolute size, it's usually easier
83 to take advantage of the ability to specify a partial
84 font description using 'font'; you can use
85 <literal>font='12.5'</literal> rather than
86 <literal>size='12800'</literal>.
91 <term>font_style<footnoteref linkend='since_1_21'/></term>
94 One of 'normal', 'oblique', 'italic'
99 <term>font_weight<footnoteref linkend='since_1_21'/></term>
102 One of 'ultralight', 'light', 'normal', 'bold', 'ultrabold', 'heavy',
108 <term>font_variant<footnoteref linkend='since_1_21'/></term>
111 One of 'normal' or 'smallcaps'
116 <term>font_stretch<footnoteref linkend='since_1_21'/></term>
119 One of 'ultracondensed', 'extracondensed', 'condensed',
120 'semicondensed', 'normal', 'semiexpanded', 'expanded',
121 'extraexpanded', 'ultraexpanded'
126 <term>foreground</term>
127 <term>fgcolor<footnoteref linkend='since_1_21'/></term>
130 An RGB color specification such as '#00FF00' or a color name such as
136 <term>background</term>
137 <term>bgcolor<footnoteref linkend='since_1_21'/></term>
139 An RGB color specification such as '#00FF00' or a color name such as
144 <varlistentry><term>underline</term>
146 One of 'none', 'single', 'double', 'low', 'error'
150 <varlistentry><term>underline_color</term>
152 The color of underlines; an RGB color specification such as '#00FF00'
153 or a color name such as 'red'
157 <varlistentry><term>rise</term>
159 Vertical displacement, in 10000ths of an em. Can be negative for
160 subscript, positive for superscript.
164 <varlistentry><term>strikethrough</term>
166 'true' or 'false' whether to strike through the text
170 <varlistentry><term>strikethrough_color</term>
172 The color of strikethrough lines; an RGB color specification such as
173 '#00FF00' or a color name such as 'red'
177 <varlistentry><term>fallback</term>
179 'true' or 'false' whether to enable fallback. If disabled, then characters
180 will only be used from the closest matching font on the system. No fallback
181 will be done to other fonts on the system that might contain the characters
182 in the text. Fallback is enabled by default. Most applications should not
187 <varlistentry><term>lang</term>
189 A language code, indicating the text language
193 <varlistentry><term>letter_spacing</term>
195 Inter-letter spacing in 1024ths of a point.
199 <varlistentry><term>gravity</term>
201 One of 'south', 'east', 'north', 'west', 'auto'.
205 <varlistentry><term>gravity_hint</term>
207 One of 'natural', 'strong', 'line'.
216 The following convenience tags are provided:
218 <variablelist><title>Convenience tags</title>
219 <varlistentry><term>b</term>
224 <varlistentry><term>big</term>
226 Makes font relatively larger, equivalent to <span size="larger">
229 <varlistentry><term>i</term>
234 <varlistentry><term>s</term>
239 <varlistentry><term>sub</term>
244 <varlistentry><term>sup</term>
249 <varlistentry><term>small</term>
251 Makes font relatively smaller, equivalent to <span size="smaller">
254 <varlistentry><term>tt</term>
259 <varlistentry><term>u</term>