~ubuntu-branches/debian/experimental/pygame/experimental

« back to all changes in this revision

Viewing changes to docs/ref/font.html

  • Committer: Package Import Robot
  • Author(s): Vincent Cheng
  • Date: 2013-02-21 00:23:03 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20130221002303-08xmo02oym2hxjee
Tags: 1.9.2~pre~r3189-1
* New upstream hg snapshot (rev 3189).
* Avoid potentially overriding a symlink in python3.2-dev. (Closes: #700997)
* Generate correct versioned dependency on python-numpy following ABI change
  using the dh_numpy and dh_numpy3 helpers. (Closes: #698169)
  - Add build-depends on python3-numpy.
* Fix a number of failing tests that rely on pygame being tested with OpenGL
  and a graphical display available, as well as audio/video devices.
* Remove deprecated DMUA flag in debian/control.
* Fix lintian tag vcs-field-not-canonical.
* Update Standards version from 3.9.3 to 3.9.4, no updates required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
 
 
4
 
<html xmlns="http://www.w3.org/1999/xhtml">
5
 
  <head>
6
 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
 
    
8
 
    <title>pygame.font &mdash; Pygame v1.9.2 documentation</title>
9
 
    <link rel="stylesheet" href="../_static/pygame.css" type="text/css" />
10
 
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
11
 
    <script type="text/javascript">
12
 
      var DOCUMENTATION_OPTIONS = {
13
 
        URL_ROOT:    '../',
14
 
        VERSION:     '1.9.2',
15
 
        COLLAPSE_INDEX: false,
16
 
        FILE_SUFFIX: '.html',
17
 
        HAS_SOURCE:  true
18
 
      };
19
 
    </script>
20
 
    <script type="text/javascript" src="../_static/jquery.js"></script>
21
 
    <script type="text/javascript" src="../_static/underscore.js"></script>
22
 
    <script type="text/javascript" src="../_static/doctools.js"></script>
23
 
    <link rel="shortcut icon" href="../_static/pygame.ico"/>
24
 
    <link rel="top" title="Pygame v1.9.2 documentation" href="../index.html" />
25
 
    <link rel="next" title="pygame.freetype" href="freetype.html" />
26
 
    <link rel="prev" title="pygame.examples" href="examples.html" /> 
27
 
  </head>
28
 
  <body>  
29
 
 
30
 
    <div class="document">
31
 
 
32
 
  <div class="header">
33
 
    <table>
34
 
      <tr>
35
 
        <td class="logo">
36
 
          <a href="http://www.pygame.org/">
37
 
            <img src="../_static/pygame_tiny.png"/>
38
 
          </a>
39
 
          <h5>pygame documentation</h5>
40
 
        </td>
41
 
        <td class="pagelinks">
42
 
          <p class="top">
43
 
            ||
44
 
            <a href="http://www.pygame.org/">Pygame Home</a> ||
45
 
            <a href="../index.html">Help Contents</a> ||
46
 
            <a href="../genindex.html">Reference Index</a> ||
47
 
          </p>
48
 
          <p class="bottom">
49
 
            <a href="camera.html">camera</a> || 
50
 
            <a href="cdrom.html">cdrom</a> || 
51
 
            <a href="color.html">Color</a> || 
52
 
            <a href="cursors.html">cursors</a> || 
53
 
            <a href="display.html">display</a> || 
54
 
            <a href="draw.html">draw</a> || 
55
 
            <a href="event.html">event</a> || 
56
 
            <a href="examples.html">examples</a> || 
57
 
            <a href="font.html">font</a> || 
58
 
            <a href="freetype.html">freetype</a> || 
59
 
            <a href="gfxdraw.html">gfxdraw</a> || 
60
 
            <a href="image.html">image</a> || 
61
 
            <a href="joystick.html">joystick</a> || 
62
 
            <a href="key.html">key</a> || 
63
 
            <a href="locals.html">locals</a> || 
64
 
            <a href="mask.html">mask</a> || 
65
 
            <a href="math.html">math</a> || 
66
 
            <a href="midi.html">midi</a> || 
67
 
            <a href="mixer.html">mixer</a> || 
68
 
            <a href="mouse.html">mouse</a> || 
69
 
            <a href="movie.html">movie</a> || 
70
 
            <a href="music.html">music</a> || 
71
 
            <a href="overlay.html">Overlay</a> || 
72
 
            <a href="pixelarray.html">PixelArray</a> || 
73
 
            <a href="pixelcopy.html">pixelcopy</a> || 
74
 
            <a href="pygame.html">pygame</a> || 
75
 
            <a href="rect.html">Rect</a> || 
76
 
            <a href="scrap.html">scrap</a> || 
77
 
            <a href="sndarray.html">sndarray</a> || 
78
 
            <a href="sprite.html">sprite</a> || 
79
 
            <a href="surface.html">Surface</a> || 
80
 
            <a href="surfarray.html">surfarray</a> || 
81
 
            <a href="tests.html">tests</a> || 
82
 
            <a href="time.html">time</a> || 
83
 
            <a href="transform.html">transform</a> || 
84
 
            <a href="pygame.html#module-pygame.version">version</a>
85
 
          </p>
86
 
        </td>
87
 
      </tr>
88
 
    </table>
89
 
  </div>
90
 
 
91
 
      <div class="documentwrapper">
92
 
          <div class="body">
93
 
            
94
 
  <div class="sectionwrapper">
95
 
<div class="section" id="module-pygame.font">
96
 
<span id="pygame-font"></span><dl class="definition module">
97
 
<dt class="title module">
98
 
<tt class="docutils literal"><span class="pre">pygame.font</span></tt></dt>
99
 
<dd><div class="line-block">
100
 
<div class="line"><span class="summaryline">pygame module for loading and rendering fonts</span></div>
101
 
</div>
102
 
<table border="1" class="toc docutils">
103
 
<colgroup>
104
 
<col width="36%" />
105
 
<col width="1%" />
106
 
<col width="63%" />
107
 
</colgroup>
108
 
<tbody valign="top">
109
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.init">pygame.font.init</a></td>
110
 
<td>—</td>
111
 
<td>initialize the font module</td>
112
 
</tr>
113
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.quit">pygame.font.quit</a></td>
114
 
<td>—</td>
115
 
<td>uninitialize the font module</td>
116
 
</tr>
117
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.get_init">pygame.font.get_init</a></td>
118
 
<td>—</td>
119
 
<td>true if the font module is initialized</td>
120
 
</tr>
121
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.get_default_font">pygame.font.get_default_font</a></td>
122
 
<td>—</td>
123
 
<td>get the filename of the default font</td>
124
 
</tr>
125
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.get_fonts">pygame.font.get_fonts</a></td>
126
 
<td>—</td>
127
 
<td>get all available fonts</td>
128
 
</tr>
129
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.match_font">pygame.font.match_font</a></td>
130
 
<td>—</td>
131
 
<td>find a specific font on the system</td>
132
 
</tr>
133
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.SysFont">pygame.font.SysFont</a></td>
134
 
<td>—</td>
135
 
<td>create a Font object from the system fonts</td>
136
 
</tr>
137
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font">pygame.font.Font</a></td>
138
 
<td>—</td>
139
 
<td>create a new Font object from a file</td>
140
 
</tr>
141
 
</tbody>
142
 
</table>
143
 
<p>The font module allows for rendering TrueType fonts into a new Surface object.
144
 
It accepts any UCS-2 character (&#8216;u0001&#8217; to &#8216;uFFFF&#8217;). This module is optional
145
 
and requires SDL_ttf as a dependency. You should test that <a class="tooltip reference internal" href="#module-pygame.font" title=""><tt class="xref py py-mod docutils literal"><span class="pre">pygame.font</span></tt><span class="tooltip-content">pygame module for loading and rendering fonts</span></a>
146
 
is available and initialized before attempting to use the module.</p>
147
 
<p>Most of the work done with fonts are done by using the actual Font objects. The
148
 
module by itself only has routines to initialize the module and create Font
149
 
objects with <tt class="docutils literal"><span class="pre">pygame.font.Font()</span></tt>.</p>
150
 
<p>You can load fonts from the system by using the <tt class="docutils literal"><span class="pre">pygame.font.SysFont()</span></tt>
151
 
function. There are a few other functions to help lookup the system fonts.</p>
152
 
<p>Pygame comes with a builtin default font. This can always be accessed by
153
 
passing None as the font name.</p>
154
 
<p>To use the <a class="tooltip reference internal" href="freetype.html#module-pygame.freetype" title=""><tt class="xref py py-mod docutils literal"><span class="pre">pygame.freetype</span></tt><span class="tooltip-content">Enhanced Pygame module for loading and rendering computer fonts</span></a> based <tt class="xref py py-mod docutils literal"><span class="pre">pygame.ftfont</span></tt> as
155
 
<a class="tooltip reference internal" href="#module-pygame.font" title=""><tt class="xref py py-mod docutils literal"><span class="pre">pygame.font</span></tt><span class="tooltip-content">pygame module for loading and rendering fonts</span></a> define the enviroment variable PYGAME_FREETYPE before the
156
 
first import of <a class="tooltip reference internal" href="pygame.html#module-pygame" title=""><tt class="xref py py-mod docutils literal"><span class="pre">pygame</span></tt><span class="tooltip-content">the top level pygame package</span></a>. <tt class="xref py py-mod docutils literal"><span class="pre">pygame.ftfont</span></tt> is a <a class="tooltip reference internal" href="#module-pygame.font" title=""><tt class="xref py py-mod docutils literal"><span class="pre">pygame.font</span></tt><span class="tooltip-content">pygame module for loading and rendering fonts</span></a>
157
 
compatible module that passes all but one of the font module unit tests:
158
 
it does not have the UCS-2 limitation of the SDL_ttf based font module, so
159
 
fails to raise an exception for a code point greater than &#8216;uFFFF&#8217;. If
160
 
<a class="tooltip reference internal" href="freetype.html#module-pygame.freetype" title=""><tt class="xref py py-mod docutils literal"><span class="pre">pygame.freetype</span></tt><span class="tooltip-content">Enhanced Pygame module for loading and rendering computer fonts</span></a> is unavailable then the SDL_ttf font module will be
161
 
loaded instead.</p>
162
 
<dl class="definition function">
163
 
<dt class="title" id="pygame.font.init">
164
 
<tt class="descclassname">pygame.font.</tt><tt class="descname">init</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.init" title="Permalink to this definition">¶</a></dt>
165
 
<dd><div class="line-block">
166
 
<div class="line"><span class="summaryline">initialize the font module</span></div>
167
 
<div class="line"><span class="signature">init() -&gt; None</span></div>
168
 
</div>
169
 
<p>This method is called automatically by <tt class="docutils literal"><span class="pre">pygame.init()</span></tt>. It initializes the
170
 
font module. The module must be initialized before any other functions will
171
 
work.</p>
172
 
<p>It is safe to call this function more than once.</p>
173
 
</dd></dl>
174
 
 
175
 
<dl class="definition function">
176
 
<dt class="title" id="pygame.font.quit">
177
 
<tt class="descclassname">pygame.font.</tt><tt class="descname">quit</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.quit" title="Permalink to this definition">¶</a></dt>
178
 
<dd><div class="line-block">
179
 
<div class="line"><span class="summaryline">uninitialize the font module</span></div>
180
 
<div class="line"><span class="signature">quit() -&gt; None</span></div>
181
 
</div>
182
 
<p>Manually uninitialize SDL_ttf&#8217;s font system. This is called automatically by
183
 
<tt class="docutils literal"><span class="pre">pygame.quit()</span></tt>.</p>
184
 
<p>It is safe to call this function even if font is currently not initialized.</p>
185
 
</dd></dl>
186
 
 
187
 
<dl class="definition function">
188
 
<dt class="title" id="pygame.font.get_init">
189
 
<tt class="descclassname">pygame.font.</tt><tt class="descname">get_init</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.get_init" title="Permalink to this definition">¶</a></dt>
190
 
<dd><div class="line-block">
191
 
<div class="line"><span class="summaryline">true if the font module is initialized</span></div>
192
 
<div class="line"><span class="signature">get_init() -&gt; bool</span></div>
193
 
</div>
194
 
<p>Test if the font module is initialized or not.</p>
195
 
</dd></dl>
196
 
 
197
 
<dl class="definition function">
198
 
<dt class="title" id="pygame.font.get_default_font">
199
 
<tt class="descclassname">pygame.font.</tt><tt class="descname">get_default_font</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.get_default_font" title="Permalink to this definition">¶</a></dt>
200
 
<dd><div class="line-block">
201
 
<div class="line"><span class="summaryline">get the filename of the default font</span></div>
202
 
<div class="line"><span class="signature">get_default_font() -&gt; string</span></div>
203
 
</div>
204
 
<p>Return the filename of the system font. This is not the full path to the
205
 
file. This file can usually be found in the same directory as the font
206
 
module, but it can also be bundled in separate archives.</p>
207
 
</dd></dl>
208
 
 
209
 
<dl class="definition function">
210
 
<dt class="title" id="pygame.font.get_fonts">
211
 
<tt class="descclassname">pygame.font.</tt><tt class="descname">get_fonts</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.get_fonts" title="Permalink to this definition">¶</a></dt>
212
 
<dd><div class="line-block">
213
 
<div class="line"><span class="summaryline">get all available fonts</span></div>
214
 
<div class="line"><span class="signature">get_fonts() -&gt; list of strings</span></div>
215
 
</div>
216
 
<p>Returns a list of all the fonts available on the system. The names of the
217
 
fonts will be set to lowercase with all spaces and punctuation removed. This
218
 
works on most systems, but some will return an empty list if they cannot
219
 
find fonts.</p>
220
 
</dd></dl>
221
 
 
222
 
<dl class="definition function">
223
 
<dt class="title" id="pygame.font.match_font">
224
 
<tt class="descclassname">pygame.font.</tt><tt class="descname">match_font</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.match_font" title="Permalink to this definition">¶</a></dt>
225
 
<dd><div class="line-block">
226
 
<div class="line"><span class="summaryline">find a specific font on the system</span></div>
227
 
<div class="line"><span class="signature">match_font(name, bold=False, italic=False) -&gt; path</span></div>
228
 
</div>
229
 
<p>Returns the full path to a font file on the system. If bold or italic are
230
 
set to true, this will attempt to find the correct family of font.</p>
231
 
<p>The font name can actually be a comma separated list of font names to try.
232
 
If none of the given names are found, None is returned.</p>
233
 
<p>Example:</p>
234
 
<div class="highlight-python"><div class="highlight"><pre><span class="k">print</span> <span class="n">pygame</span><span class="o">.</span><span class="n">font</span><span class="o">.</span><span class="n">match_font</span><span class="p">(</span><span class="s">&#39;bitstreamverasans&#39;</span><span class="p">)</span>
235
 
<span class="c"># output is: /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf</span>
236
 
<span class="c"># (but only if you have Vera on your system)</span>
237
 
</pre></div>
238
 
</div>
239
 
</dd></dl>
240
 
 
241
 
<dl class="definition function">
242
 
<dt class="title" id="pygame.font.SysFont">
243
 
<tt class="descclassname">pygame.font.</tt><tt class="descname">SysFont</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.SysFont" title="Permalink to this definition">¶</a></dt>
244
 
<dd><div class="line-block">
245
 
<div class="line"><span class="summaryline">create a Font object from the system fonts</span></div>
246
 
<div class="line"><span class="signature">SysFont(name, size, bold=False, italic=False) -&gt; Font</span></div>
247
 
</div>
248
 
<p>Return a new Font object that is loaded from the system fonts. The font will
249
 
match the requested bold and italic flags. If a suitable system font is not
250
 
found this will fallback on loading the default pygame font. The font name
251
 
can be a comma separated list of font names to look for.</p>
252
 
</dd></dl>
253
 
 
254
 
<dl class="definition class">
255
 
<dt class="title" id="pygame.font.Font">
256
 
<em class="property">class </em><tt class="descclassname">pygame.font.</tt><tt class="descname">Font</tt><a class="headerlink" href="#pygame.font.Font" title="Permalink to this definition">¶</a></dt>
257
 
<dd><div class="line-block">
258
 
<div class="line"><span class="summaryline">create a new Font object from a file</span></div>
259
 
<div class="line"><span class="signature">Font(filename, size) -&gt; Font</span></div>
260
 
<div class="line"><span class="signature">Font(object, size) -&gt; Font</span></div>
261
 
</div>
262
 
<table border="1" class="toc docutils">
263
 
<colgroup>
264
 
<col width="32%" />
265
 
<col width="1%" />
266
 
<col width="67%" />
267
 
</colgroup>
268
 
<tbody valign="top">
269
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.render">pygame.font.Font.render</a></td>
270
 
<td>—</td>
271
 
<td>draw text on a new Surface</td>
272
 
</tr>
273
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.size">pygame.font.Font.size</a></td>
274
 
<td>—</td>
275
 
<td>determine the amount of space needed to render text</td>
276
 
</tr>
277
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.set_underline">pygame.font.Font.set_underline</a></td>
278
 
<td>—</td>
279
 
<td>control if text is rendered with an underline</td>
280
 
</tr>
281
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.get_underline">pygame.font.Font.get_underline</a></td>
282
 
<td>—</td>
283
 
<td>check if text will be rendered with an underline</td>
284
 
</tr>
285
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.set_bold">pygame.font.Font.set_bold</a></td>
286
 
<td>—</td>
287
 
<td>enable fake rendering of bold text</td>
288
 
</tr>
289
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.get_bold">pygame.font.Font.get_bold</a></td>
290
 
<td>—</td>
291
 
<td>check if text will be rendered bold</td>
292
 
</tr>
293
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.set_italic">pygame.font.Font.set_italic</a></td>
294
 
<td>—</td>
295
 
<td>enable fake rendering of italic text</td>
296
 
</tr>
297
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.metrics">pygame.font.Font.metrics</a></td>
298
 
<td>—</td>
299
 
<td>Gets the metrics for each character in the pased string.</td>
300
 
</tr>
301
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.get_italic">pygame.font.Font.get_italic</a></td>
302
 
<td>—</td>
303
 
<td>check if the text will be rendered italic</td>
304
 
</tr>
305
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.get_linesize">pygame.font.Font.get_linesize</a></td>
306
 
<td>—</td>
307
 
<td>get the line space of the font text</td>
308
 
</tr>
309
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.get_height">pygame.font.Font.get_height</a></td>
310
 
<td>—</td>
311
 
<td>get the height of the font</td>
312
 
</tr>
313
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.get_ascent">pygame.font.Font.get_ascent</a></td>
314
 
<td>—</td>
315
 
<td>get the ascent of the font</td>
316
 
</tr>
317
 
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.get_descent">pygame.font.Font.get_descent</a></td>
318
 
<td>—</td>
319
 
<td>get the descent of the font</td>
320
 
</tr>
321
 
</tbody>
322
 
</table>
323
 
<p>Load a new font from a given filename or a python file object. The size is
324
 
the height of the font in pixels. If the filename is None the Pygame default
325
 
font will be loaded. If a font cannot be loaded from the arguments given an
326
 
exception will be raised. Once the font is created the size cannot be
327
 
changed.</p>
328
 
<p>Font objects are mainly used to render text into new Surface objects. The
329
 
render can emulate bold or italic features, but it is better to load from a
330
 
font with actual italic or bold glyphs. The rendered text can be regular
331
 
strings or unicode.</p>
332
 
<dl class="definition method">
333
 
<dt class="title" id="pygame.font.Font.render">
334
 
<tt class="descname">render</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.render" title="Permalink to this definition">¶</a></dt>
335
 
<dd><div class="line-block">
336
 
<div class="line"><span class="summaryline">draw text on a new Surface</span></div>
337
 
<div class="line"><span class="signature">render(text, antialias, color, background=None) -&gt; Surface</span></div>
338
 
</div>
339
 
<p>This creates a new Surface with the specified text rendered on it. Pygame
340
 
provides no way to directly draw text on an existing Surface: instead you
341
 
must use <tt class="docutils literal"><span class="pre">Font.render()</span></tt> to create an image (Surface) of the text, then
342
 
blit this image onto another Surface.</p>
343
 
<p>The text can only be a single line: newline characters are not rendered.
344
 
Null characters (&#8216;x00&#8217;) raise a TypeError. Both Unicode and char (byte)
345
 
strings are accepted. For Unicode strings only UCS-2 characters (&#8216;u0001&#8217;
346
 
to &#8216;uFFFF&#8217;) are recognized. Anything greater raises a UnicodeError. For
347
 
char strings a <tt class="docutils literal"><span class="pre">LATIN1</span></tt> encoding is assumed. The antialias argument is
348
 
a boolean: if true the characters will have smooth edges. The color
349
 
argument is the color of the text [e.g.: (0,0,255) for blue]. The
350
 
optional background argument is a color to use for the text background.
351
 
If no background is passed the area outside the text will be transparent.</p>
352
 
<p>The Surface returned will be of the dimensions required to hold the text.
353
 
(the same as those returned by Font.size()). If an empty string is passed
354
 
for the text, a blank surface will be returned that is one pixel wide and
355
 
the height of the font.</p>
356
 
<p>Depending on the type of background and antialiasing used, this returns
357
 
different types of Surfaces. For performance reasons, it is good to know
358
 
what type of image will be used. If antialiasing is not used, the return
359
 
image will always be an 8bit image with a two color palette. If the
360
 
background is transparent a colorkey will be set. Antialiased images are
361
 
rendered to 24-bit <tt class="docutils literal"><span class="pre">RGB</span></tt> images. If the background is transparent a
362
 
pixel alpha will be included.</p>
363
 
<p>Optimization: if you know that the final destination for the text (on the
364
 
screen) will always have a solid background, and the text is antialiased,
365
 
you can improve performance by specifying the background color. This will
366
 
cause the resulting image to maintain transparency information by
367
 
colorkey rather than (much less efficient) alpha values.</p>
368
 
<p>If you render &#8216;n&#8217; a unknown char will be rendered. Usually a rectangle.
369
 
Instead you need to handle new lines yourself.</p>
370
 
<p>Font rendering is not thread safe: only a single thread can render text
371
 
at any time.</p>
372
 
</dd></dl>
373
 
 
374
 
<dl class="definition method">
375
 
<dt class="title" id="pygame.font.Font.size">
376
 
<tt class="descname">size</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.size" title="Permalink to this definition">¶</a></dt>
377
 
<dd><div class="line-block">
378
 
<div class="line"><span class="summaryline">determine the amount of space needed to render text</span></div>
379
 
<div class="line"><span class="signature">size(text) -&gt; (width, height)</span></div>
380
 
</div>
381
 
<p>Returns the dimensions needed to render the text. This can be used to
382
 
help determine the positioning needed for text before it is rendered. It
383
 
can also be used for wordwrapping and other layout effects.</p>
384
 
<p>Be aware that most fonts use kerning which adjusts the widths for
385
 
specific letter pairs. For example, the width for &#8220;ae&#8221; will not always
386
 
match the width for &#8220;a&#8221; + &#8220;e&#8221;.</p>
387
 
</dd></dl>
388
 
 
389
 
<dl class="definition method">
390
 
<dt class="title" id="pygame.font.Font.set_underline">
391
 
<tt class="descname">set_underline</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.set_underline" title="Permalink to this definition">¶</a></dt>
392
 
<dd><div class="line-block">
393
 
<div class="line"><span class="summaryline">control if text is rendered with an underline</span></div>
394
 
<div class="line"><span class="signature">set_underline(bool) -&gt; None</span></div>
395
 
</div>
396
 
<p>When enabled, all rendered fonts will include an underline. The underline
397
 
is always one pixel thick, regardless of font size. This can be mixed
398
 
with the bold and italic modes.</p>
399
 
</dd></dl>
400
 
 
401
 
<dl class="definition method">
402
 
<dt class="title" id="pygame.font.Font.get_underline">
403
 
<tt class="descname">get_underline</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.get_underline" title="Permalink to this definition">¶</a></dt>
404
 
<dd><div class="line-block">
405
 
<div class="line"><span class="summaryline">check if text will be rendered with an underline</span></div>
406
 
<div class="line"><span class="signature">get_underline() -&gt; bool</span></div>
407
 
</div>
408
 
<p>Return True when the font underline is enabled.</p>
409
 
</dd></dl>
410
 
 
411
 
<dl class="definition method">
412
 
<dt class="title" id="pygame.font.Font.set_bold">
413
 
<tt class="descname">set_bold</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.set_bold" title="Permalink to this definition">¶</a></dt>
414
 
<dd><div class="line-block">
415
 
<div class="line"><span class="summaryline">enable fake rendering of bold text</span></div>
416
 
<div class="line"><span class="signature">set_bold(bool) -&gt; None</span></div>
417
 
</div>
418
 
<p>Enables the bold rendering of text. This is a fake stretching of the font
419
 
that doesn&#8217;t look good on many font types. If possible load the font from
420
 
a real bold font file. While bold, the font will have a different width
421
 
than when normal. This can be mixed with the italic and underline modes.</p>
422
 
</dd></dl>
423
 
 
424
 
<dl class="definition method">
425
 
<dt class="title" id="pygame.font.Font.get_bold">
426
 
<tt class="descname">get_bold</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.get_bold" title="Permalink to this definition">¶</a></dt>
427
 
<dd><div class="line-block">
428
 
<div class="line"><span class="summaryline">check if text will be rendered bold</span></div>
429
 
<div class="line"><span class="signature">get_bold() -&gt; bool</span></div>
430
 
</div>
431
 
<p>Return True when the font bold rendering mode is enabled.</p>
432
 
</dd></dl>
433
 
 
434
 
<dl class="definition method">
435
 
<dt class="title" id="pygame.font.Font.set_italic">
436
 
<tt class="descname">set_italic</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.set_italic" title="Permalink to this definition">¶</a></dt>
437
 
<dd><div class="line-block">
438
 
<div class="line"><span class="summaryline">enable fake rendering of italic text</span></div>
439
 
<div class="line"><span class="signature">set_italic(bool) -&gt; None</span></div>
440
 
</div>
441
 
<p>Enables fake rendering of italic text. This is a fake skewing of the font
442
 
that doesn&#8217;t look good on many font types. If possible load the font from
443
 
a real italic font file. While italic the font will have a different
444
 
width than when normal. This can be mixed with the bold and underline
445
 
modes.</p>
446
 
</dd></dl>
447
 
 
448
 
<dl class="definition method">
449
 
<dt class="title" id="pygame.font.Font.metrics">
450
 
<tt class="descname">metrics</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.metrics" title="Permalink to this definition">¶</a></dt>
451
 
<dd><div class="line-block">
452
 
<div class="line"><span class="summaryline">Gets the metrics for each character in the pased string.</span></div>
453
 
<div class="line"><span class="signature">metrics(text) -&gt; list</span></div>
454
 
</div>
455
 
<p>The list contains tuples for each character, which contain the minimum
456
 
<tt class="docutils literal"><span class="pre">X</span></tt> offset, the maximum <tt class="docutils literal"><span class="pre">X</span></tt> offset, the minimum <tt class="docutils literal"><span class="pre">Y</span></tt> offset, the
457
 
maximum <tt class="docutils literal"><span class="pre">Y</span></tt> offset and the advance offset (bearing plus width) of the
458
 
character. [(minx, maxx, miny, maxy, advance), (minx, maxx, miny, maxy,
459
 
advance), ...]. None is entered in the list for each unrecognized
460
 
character.</p>
461
 
</dd></dl>
462
 
 
463
 
<dl class="definition method">
464
 
<dt class="title" id="pygame.font.Font.get_italic">
465
 
<tt class="descname">get_italic</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.get_italic" title="Permalink to this definition">¶</a></dt>
466
 
<dd><div class="line-block">
467
 
<div class="line"><span class="summaryline">check if the text will be rendered italic</span></div>
468
 
<div class="line"><span class="signature">get_italic() -&gt; bool</span></div>
469
 
</div>
470
 
<p>Return True when the font italic rendering mode is enabled.</p>
471
 
</dd></dl>
472
 
 
473
 
<dl class="definition method">
474
 
<dt class="title" id="pygame.font.Font.get_linesize">
475
 
<tt class="descname">get_linesize</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.get_linesize" title="Permalink to this definition">¶</a></dt>
476
 
<dd><div class="line-block">
477
 
<div class="line"><span class="summaryline">get the line space of the font text</span></div>
478
 
<div class="line"><span class="signature">get_linesize() -&gt; int</span></div>
479
 
</div>
480
 
<p>Return the height in pixels for a line of text with the font. When
481
 
rendering multiple lines of text this is the recommended amount of space
482
 
between lines.</p>
483
 
</dd></dl>
484
 
 
485
 
<dl class="definition method">
486
 
<dt class="title" id="pygame.font.Font.get_height">
487
 
<tt class="descname">get_height</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.get_height" title="Permalink to this definition">¶</a></dt>
488
 
<dd><div class="line-block">
489
 
<div class="line"><span class="summaryline">get the height of the font</span></div>
490
 
<div class="line"><span class="signature">get_height() -&gt; int</span></div>
491
 
</div>
492
 
<p>Return the height in pixels of the actual rendered text. This is the
493
 
average size for each glyph in the font.</p>
494
 
</dd></dl>
495
 
 
496
 
<dl class="definition method">
497
 
<dt class="title" id="pygame.font.Font.get_ascent">
498
 
<tt class="descname">get_ascent</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.get_ascent" title="Permalink to this definition">¶</a></dt>
499
 
<dd><div class="line-block">
500
 
<div class="line"><span class="summaryline">get the ascent of the font</span></div>
501
 
<div class="line"><span class="signature">get_ascent() -&gt; int</span></div>
502
 
</div>
503
 
<p>Return the height in pixels for the font ascent. The ascent is the number
504
 
of pixels from the font baseline to the top of the font.</p>
505
 
</dd></dl>
506
 
 
507
 
<dl class="definition method">
508
 
<dt class="title" id="pygame.font.Font.get_descent">
509
 
<tt class="descname">get_descent</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.get_descent" title="Permalink to this definition">¶</a></dt>
510
 
<dd><div class="line-block">
511
 
<div class="line"><span class="summaryline">get the descent of the font</span></div>
512
 
<div class="line"><span class="signature">get_descent() -&gt; int</span></div>
513
 
</div>
514
 
<p>Return the height in pixels for the font descent. The descent is the
515
 
number of pixels from the font baseline to the bottom of the font.</p>
516
 
</dd></dl>
517
 
 
518
 
</dd></dl>
519
 
 
520
 
</dd></dl>
521
 
 
522
 
</div>
523
 
 
524
 
  </div>
525
 
          </div>
526
 
      </div>
527
 
      <div class="clearer"></div>
528
 
    </div>
529
 
    <div class="related">
530
 
      <h3>Navigation</h3>
531
 
      <ul>
532
 
        <li class="right" style="margin-right: 10px">
533
 
          <a href="../genindex.html" title="General Index"
534
 
             accesskey="I">index</a></li>
535
 
        <li class="right" >
536
 
          <a href="freetype.html" title="pygame.freetype"
537
 
             accesskey="N">next</a> |</li>
538
 
        <li class="right" >
539
 
          <a href="examples.html" title="pygame.examples"
540
 
             accesskey="P">previous</a> |</li>
541
 
        <li><a href="../index.html">Pygame v1.9.2 documentation</a> &raquo;</li>
542
 
    <script type="text/javascript" src="jquery.plugin.docscomments.js"></script>
543
 
 
544
 
      </ul>
545
 
    </div>
546
 
    <div class="footer">
547
 
        &copy; Copyright 2011, Pygame Developers.
548
 
    </div>
549
 
  </body>
550
 
</html>
 
 
b'\\ No newline at end of file'