summaryrefslogtreecommitdiff
path: root/docs/reference/pygtk-pango-markup.xml
blob: b7ef3c4f2ec4d1db94f00a5b11d970eb979665cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?xml version="1.0" standalone="no"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

<refentry id="pango-markup-language">
  <refnamediv>
    <refname>The Pango Markup Language</refname>
    <refpurpose>a simple markup language for encoding attributes with text.</refpurpose>
  </refnamediv>

  <refsect1>
    <title>Description</title>

    <para>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:</para>

      <literal>&lt;span foreground="blue" size="100"&gt;Blue text&lt;/span&gt; is &lt;i&gt;cool&lt;/i&gt;!</literal>

    <para>Using the pango markup language to markup text and parsing the
result with the <link
linkend="function-pango--parse-markup"><function>pango.parse_markup</function>()</link> 
function is a convenient way to generate the <link
linkend="class-pangoattrlist"><classname>pango.AttrList</classname></link>
and plain text that can be used in a <link
linkend="class-pangolayout"><classname>pango.Layout</classname></link>.</para>

      <para>The root tag of a marked-up document is
<literal>&lt;markup&gt;</literal>, but the <link
linkend="function-pango--parse-markup"><function>pango.parse_markup</function>()</link> 
function allows you to omit this tag, so you will most likely never need to
use it. The most general markup tag is <literal>&lt;span&gt;</literal>. The
<literal>&lt;span&gt;</literal> tag has the following attributes:</para>

      <variablelist>
	<varlistentry>
	  <term><literal>font_desc</literal></term>
	  <listitem>
	    <simpara>A 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.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>font_family</literal></term>
	  <listitem>
	    <simpara>A font family name such as "normal", "sans", "serif" or
"monospace".</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>face</literal></term>
	  <listitem>
	    <simpara>A synonym for font_family</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>size</literal></term>
	  <listitem>
	    <simpara>The 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'.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>style</literal></term>
	  <listitem>
	    <simpara>The slant style - one of 'normal', 'oblique', or
'italic'</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>weight</literal></term>
	  <listitem>
	    <simpara>The font weight - one of 'ultralight', 'light',
'normal', 'bold', 'ultrabold', 'heavy', or a numeric weight.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>variant</literal></term>
	  <listitem>
	    <simpara>The font variant - either 'normal' or
'smallcaps'.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>stretch</literal></term>
	  <listitem>
	    <simpara>The font width - one of 'ultracondensed',
'extracondensed', 'condensed', 'semicondensed', 'normal', 'semiexpanded',
'expanded', 'extraexpanded', 'ultraexpanded'.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>foreground</literal></term>
	  <listitem>
	    <simpara>An RGB color specification such as '#00FF00' or a color
name such as 'red'.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>background</literal></term>
	  <listitem>
	    <simpara>An RGB color specification such as '#00FF00' or a color
name such as 'red'.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>underline</literal></term>
	  <listitem>
	    <simpara>The underline style - one of 'single', 'double', 'low',
or 'none'.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>rise</literal></term>
	  <listitem>
	    <simpara>The vertical displacement from the baseline, in ten
thousandths of an em. Can be negative for subscript, positive for
superscript.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>strikethrough</literal></term>
	  <listitem>
	    <simpara>'true' or 'false' whether to strike through the
text.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>fallback</literal></term>
	  <listitem>
	  <simpara>If <literal>True</literal> 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.</simpara></listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>lang</literal></term>
	  <listitem>
	    <simpara>A language code, indicating the text
language.</simpara>
	  </listitem>
	</varlistentry>
      </variablelist>

    <para>There are a number of convenience tags that encapsulate specific
span options:</para>

      <variablelist>
	<varlistentry>
	  <term><literal>b</literal></term>
	  <listitem>
	    <simpara>Make the text bold.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>big</literal></term>
	  <listitem>
	  <simpara>Makes font relatively larger, equivalent to &lt;span
size="larger"&gt;.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>i</literal></term>
	  <listitem>
	    <simpara>Make the text italic.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>s</literal></term>
	  <listitem>
	    <simpara>Strikethrough the text.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>sub</literal></term>
	  <listitem>
	    <simpara>Subscript the text.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>sup</literal></term>
	  <listitem>
	    <simpara>Superscript the text.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>small</literal></term>
	  <listitem>
	    <simpara>Makes font relatively smaller, equivalent to &lt;span
size="smaller"&gt;.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>tt</literal></term>
	  <listitem>
	    <simpara>Use a monospace font.</simpara>
	  </listitem>
	</varlistentry>
	<varlistentry>
	  <term><literal>u</literal></term>
	  <listitem>
	    <simpara>Underline the text.</simpara>
	  </listitem>
	</varlistentry>
      </variablelist>

  </refsect1>

</refentry>