Source

pygame / docs / ref / font.html

Full commit
  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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>pygame.font &mdash; Pygame v1.9.2 documentation</title>
    <link rel="stylesheet" href="../_static/pygame.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.9.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="shortcut icon" href="../_static/pygame.ico"/>
    <link rel="top" title="Pygame v1.9.2 documentation" href="../index.html" />
    <link rel="next" title="pygame.freetype" href="freetype.html" />
    <link rel="prev" title="pygame.examples" href="examples.html" /> 
  </head>
  <body>  

    <div class="document">

  <div class="header">
    <table>
      <tr>
	<td class="logo">
	  <a href="http://www.pygame.org/">
	    <img src="../_static/pygame_tiny.png"/>
	  </a>
	  <h5>pygame documentation</h5>
	</td>
	<td class="pagelinks">
	  <p class="top">
	    ||
	    <a href="http://www.pygame.org/">Pygame Home</a> ||
	    <a href="../index.html">Help Contents</a> ||
	    <a href="../genindex.html">Reference Index</a> ||
	  </p>
	  <p class="bottom">
	    <a href="camera.html">camera</a> || 
	    <a href="cdrom.html">cdrom</a> || 
	    <a href="color.html">Color</a> || 
	    <a href="cursors.html">cursors</a> || 
	    <a href="display.html">display</a> || 
	    <a href="draw.html">draw</a> || 
	    <a href="event.html">event</a> || 
	    <a href="examples.html">examples</a> || 
	    <a href="font.html">font</a> || 
	    <a href="freetype.html">freetype</a> || 
	    <a href="gfxdraw.html">gfxdraw</a> || 
	    <a href="image.html">image</a> || 
	    <a href="joystick.html">joystick</a> || 
	    <a href="key.html">key</a> || 
	    <a href="locals.html">locals</a> || 
	    <a href="mask.html">mask</a> || 
	    <a href="math.html">math</a> || 
	    <a href="midi.html">midi</a> || 
	    <a href="mixer.html">mixer</a> || 
	    <a href="mouse.html">mouse</a> || 
	    <a href="movie.html">movie</a> || 
	    <a href="music.html">music</a> || 
	    <a href="overlay.html">Overlay</a> || 
	    <a href="pixelarray.html">PixelArray</a> || 
	    <a href="pixelcopy.html">pixelcopy</a> || 
	    <a href="pygame.html">pygame</a> || 
	    <a href="rect.html">Rect</a> || 
	    <a href="scrap.html">scrap</a> || 
	    <a href="sndarray.html">sndarray</a> || 
	    <a href="sprite.html">sprite</a> || 
	    <a href="surface.html">Surface</a> || 
	    <a href="surfarray.html">surfarray</a> || 
	    <a href="tests.html">tests</a> || 
	    <a href="time.html">time</a> || 
	    <a href="transform.html">transform</a> || 
	    <a href="pygame.html#module-pygame.version">version</a>
	  </p>
	</td>
      </tr>
    </table>
  </div>

      <div class="documentwrapper">
          <div class="body">
            
  <div class="sectionwrapper">
<div class="section" id="module-pygame.font">
<span id="pygame-font"></span><dl class="definition module">
<dt class="title module">
<tt class="docutils literal"><span class="pre">pygame.font</span></tt></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">pygame module for loading and rendering fonts</span></div>
</div>
<table border="1" class="toc docutils">
<colgroup>
<col width="36%" />
<col width="1%" />
<col width="63%" />
</colgroup>
<tbody valign="top">
<tr><td><a class="toc reference external" href="font.html#pygame.font.init">pygame.font.init</a></td>
<td></td>
<td>initialize the font module</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.quit">pygame.font.quit</a></td>
<td></td>
<td>uninitialize the font module</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.get_init">pygame.font.get_init</a></td>
<td></td>
<td>true if the font module is initialized</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.get_default_font">pygame.font.get_default_font</a></td>
<td></td>
<td>get the filename of the default font</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.get_fonts">pygame.font.get_fonts</a></td>
<td></td>
<td>get all available fonts</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.match_font">pygame.font.match_font</a></td>
<td></td>
<td>find a specific font on the system</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.SysFont">pygame.font.SysFont</a></td>
<td></td>
<td>create a Font object from the system fonts</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font">pygame.font.Font</a></td>
<td></td>
<td>create a new Font object from a file</td>
</tr>
</tbody>
</table>
<p>The font module allows for rendering TrueType fonts into a new Surface object.
It accepts any UCS-2 character (&#8216;u0001&#8217; to &#8216;uFFFF&#8217;). This module is optional
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>
is available and initialized before attempting to use the module.</p>
<p>Most of the work done with fonts are done by using the actual Font objects. The
module by itself only has routines to initialize the module and create Font
objects with <tt class="docutils literal"><span class="pre">pygame.font.Font()</span></tt>.</p>
<p>You can load fonts from the system by using the <tt class="docutils literal"><span class="pre">pygame.font.SysFont()</span></tt>
function. There are a few other functions to help lookup the system fonts.</p>
<p>Pygame comes with a builtin default font. This can always be accessed by
passing None as the font name.</p>
<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 font faces</span></a> based <tt class="xref py py-mod docutils literal"><span class="pre">pygame.ftfont</span></tt> as
<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
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>
compatible module that passes all but one of the font module unit tests:
it does not have the UCS-2 limitation of the SDL_ttf based font module, so
fails to raise an exception for a code point greater than &#8216;uFFFF&#8217;. If
<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 font faces</span></a> is unavailable then the SDL_ttf font module will be
loaded instead.</p>
<dl class="definition function">
<dt class="title" id="pygame.font.init">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">initialize the font module</span></div>
<div class="line"><span class="signature">init() -&gt; None</span></div>
</div>
<p>This method is called automatically by <tt class="docutils literal"><span class="pre">pygame.init()</span></tt>. It initializes the
font module. The module must be initialized before any other functions will
work.</p>
<p>It is safe to call this function more than once.</p>
</dd></dl>

<dl class="definition function">
<dt class="title" id="pygame.font.quit">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">uninitialize the font module</span></div>
<div class="line"><span class="signature">quit() -&gt; None</span></div>
</div>
<p>Manually uninitialize SDL_ttf&#8217;s font system. This is called automatically by
<tt class="docutils literal"><span class="pre">pygame.quit()</span></tt>.</p>
<p>It is safe to call this function even if font is currently not initialized.</p>
</dd></dl>

<dl class="definition function">
<dt class="title" id="pygame.font.get_init">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">true if the font module is initialized</span></div>
<div class="line"><span class="signature">get_init() -&gt; bool</span></div>
</div>
<p>Test if the font module is initialized or not.</p>
</dd></dl>

<dl class="definition function">
<dt class="title" id="pygame.font.get_default_font">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">get the filename of the default font</span></div>
<div class="line"><span class="signature">get_default_font() -&gt; string</span></div>
</div>
<p>Return the filename of the system font. This is not the full path to the
file. This file can usually be found in the same directory as the font
module, but it can also be bundled in separate archives.</p>
</dd></dl>

<dl class="definition function">
<dt class="title" id="pygame.font.get_fonts">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">get all available fonts</span></div>
<div class="line"><span class="signature">get_fonts() -&gt; list of strings</span></div>
</div>
<p>Returns a list of all the fonts available on the system. The names of the
fonts will be set to lowercase with all spaces and punctuation removed. This
works on most systems, but some will return an empty list if they cannot
find fonts.</p>
</dd></dl>

<dl class="definition function">
<dt class="title" id="pygame.font.match_font">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">find a specific font on the system</span></div>
<div class="line"><span class="signature">match_font(name, bold=False, italic=False) -&gt; path</span></div>
</div>
<p>Returns the full path to a font file on the system. If bold or italic are
set to true, this will attempt to find the correct family of font.</p>
<p>The font name can actually be a comma separated list of font names to try.
If none of the given names are found, None is returned.</p>
<p>Example:</p>
<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>
<span class="c"># output is: /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf</span>
<span class="c"># (but only if you have Vera on your system)</span>
</pre></div>
</div>
</dd></dl>

<dl class="definition function">
<dt class="title" id="pygame.font.SysFont">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">create a Font object from the system fonts</span></div>
<div class="line"><span class="signature">SysFont(name, size, bold=False, italic=False) -&gt; Font</span></div>
</div>
<p>Return a new Font object that is loaded from the system fonts. The font will
match the requested bold and italic flags. If a suitable system font is not
found this will fallback on loading the default pygame font. The font name
can be a comma separated list of font names to look for.</p>
</dd></dl>

<dl class="definition class">
<dt class="title" id="pygame.font.Font">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">create a new Font object from a file</span></div>
<div class="line"><span class="signature">Font(filename, size) -&gt; Font</span></div>
<div class="line"><span class="signature">Font(object, size) -&gt; Font</span></div>
</div>
<table border="1" class="toc docutils">
<colgroup>
<col width="32%" />
<col width="1%" />
<col width="67%" />
</colgroup>
<tbody valign="top">
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.render">pygame.font.Font.render</a></td>
<td></td>
<td>draw text on a new Surface</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.size">pygame.font.Font.size</a></td>
<td></td>
<td>determine the amount of space needed to render text</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.set_underline">pygame.font.Font.set_underline</a></td>
<td></td>
<td>control if text is rendered with an underline</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.get_underline">pygame.font.Font.get_underline</a></td>
<td></td>
<td>check if text will be rendered with an underline</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.set_bold">pygame.font.Font.set_bold</a></td>
<td></td>
<td>enable fake rendering of bold text</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.get_bold">pygame.font.Font.get_bold</a></td>
<td></td>
<td>check if text will be rendered bold</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.set_italic">pygame.font.Font.set_italic</a></td>
<td></td>
<td>enable fake rendering of italic text</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.metrics">pygame.font.Font.metrics</a></td>
<td></td>
<td>Gets the metrics for each character in the pased string.</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.get_italic">pygame.font.Font.get_italic</a></td>
<td></td>
<td>check if the text will be rendered italic</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.get_linesize">pygame.font.Font.get_linesize</a></td>
<td></td>
<td>get the line space of the font text</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.get_height">pygame.font.Font.get_height</a></td>
<td></td>
<td>get the height of the font</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.get_ascent">pygame.font.Font.get_ascent</a></td>
<td></td>
<td>get the ascent of the font</td>
</tr>
<tr><td><a class="toc reference external" href="font.html#pygame.font.Font.get_descent">pygame.font.Font.get_descent</a></td>
<td></td>
<td>get the descent of the font</td>
</tr>
</tbody>
</table>
<p>Load a new font from a given filename or a python file object. The size is
the height of the font in pixels. If the filename is None the Pygame default
font will be loaded. If a font cannot be loaded from the arguments given an
exception will be raised. Once the font is created the size cannot be
changed.</p>
<p>Font objects are mainly used to render text into new Surface objects. The
render can emulate bold or italic features, but it is better to load from a
font with actual italic or bold glyphs. The rendered text can be regular
strings or unicode.</p>
<dl class="definition method">
<dt class="title" id="pygame.font.Font.render">
<tt class="descname">render</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.render" title="Permalink to this definition"></a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">draw text on a new Surface</span></div>
<div class="line"><span class="signature">render(text, antialias, color, background=None) -&gt; Surface</span></div>
</div>
<p>This creates a new Surface with the specified text rendered on it. Pygame
provides no way to directly draw text on an existing Surface: instead you
must use <tt class="docutils literal"><span class="pre">Font.render()</span></tt> to create an image (Surface) of the text, then
blit this image onto another Surface.</p>
<p>The text can only be a single line: newline characters are not rendered.
Null characters (&#8216;x00&#8217;) raise a TypeError. Both Unicode and char (byte)
strings are accepted. For Unicode strings only UCS-2 characters (&#8216;u0001&#8217;
to &#8216;uFFFF&#8217;) are recognized. Anything greater raises a UnicodeError. For
char strings a <tt class="docutils literal"><span class="pre">LATIN1</span></tt> encoding is assumed. The antialias argument is
a boolean: if true the characters will have smooth edges. The color
argument is the color of the text [e.g.: (0,0,255) for blue]. The
optional background argument is a color to use for the text background.
If no background is passed the area outside the text will be transparent.</p>
<p>The Surface returned will be of the dimensions required to hold the text.
(the same as those returned by Font.size()). If an empty string is passed
for the text, a blank surface will be returned that is one pixel wide and
the height of the font.</p>
<p>Depending on the type of background and antialiasing used, this returns
different types of Surfaces. For performance reasons, it is good to know
what type of image will be used. If antialiasing is not used, the return
image will always be an 8bit image with a two color palette. If the
background is transparent a colorkey will be set. Antialiased images are
rendered to 24-bit <tt class="docutils literal"><span class="pre">RGB</span></tt> images. If the background is transparent a
pixel alpha will be included.</p>
<p>Optimization: if you know that the final destination for the text (on the
screen) will always have a solid background, and the text is antialiased,
you can improve performance by specifying the background color. This will
cause the resulting image to maintain transparency information by
colorkey rather than (much less efficient) alpha values.</p>
<p>If you render &#8216;n&#8217; a unknown char will be rendered. Usually a rectangle.
Instead you need to handle new lines yourself.</p>
<p>Font rendering is not thread safe: only a single thread can render text
at any time.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.font.Font.size">
<tt class="descname">size</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.size" title="Permalink to this definition"></a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">determine the amount of space needed to render text</span></div>
<div class="line"><span class="signature">size(text) -&gt; (width, height)</span></div>
</div>
<p>Returns the dimensions needed to render the text. This can be used to
help determine the positioning needed for text before it is rendered. It
can also be used for wordwrapping and other layout effects.</p>
<p>Be aware that most fonts use kerning which adjusts the widths for
specific letter pairs. For example, the width for &#8220;ae&#8221; will not always
match the width for &#8220;a&#8221; + &#8220;e&#8221;.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.font.Font.set_underline">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">control if text is rendered with an underline</span></div>
<div class="line"><span class="signature">set_underline(bool) -&gt; None</span></div>
</div>
<p>When enabled, all rendered fonts will include an underline. The underline
is always one pixel thick, regardless of font size. This can be mixed
with the bold and italic modes.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.font.Font.get_underline">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">check if text will be rendered with an underline</span></div>
<div class="line"><span class="signature">get_underline() -&gt; bool</span></div>
</div>
<p>Return True when the font underline is enabled.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.font.Font.set_bold">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">enable fake rendering of bold text</span></div>
<div class="line"><span class="signature">set_bold(bool) -&gt; None</span></div>
</div>
<p>Enables the bold rendering of text. This is a fake stretching of the font
that doesn&#8217;t look good on many font types. If possible load the font from
a real bold font file. While bold, the font will have a different width
than when normal. This can be mixed with the italic and underline modes.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.font.Font.get_bold">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">check if text will be rendered bold</span></div>
<div class="line"><span class="signature">get_bold() -&gt; bool</span></div>
</div>
<p>Return True when the font bold rendering mode is enabled.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.font.Font.set_italic">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">enable fake rendering of italic text</span></div>
<div class="line"><span class="signature">set_italic(bool) -&gt; None</span></div>
</div>
<p>Enables fake rendering of italic text. This is a fake skewing of the font
that doesn&#8217;t look good on many font types. If possible load the font from
a real italic font file. While italic the font will have a different
width than when normal. This can be mixed with the bold and underline
modes.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.font.Font.metrics">
<tt class="descname">metrics</tt><big>(</big><big>)</big><a class="headerlink" href="#pygame.font.Font.metrics" title="Permalink to this definition"></a></dt>
<dd><div class="line-block">
<div class="line"><span class="summaryline">Gets the metrics for each character in the pased string.</span></div>
<div class="line"><span class="signature">metrics(text) -&gt; list</span></div>
</div>
<p>The list contains tuples for each character, which contain the minimum
<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
maximum <tt class="docutils literal"><span class="pre">Y</span></tt> offset and the advance offset (bearing plus width) of the
character. [(minx, maxx, miny, maxy, advance), (minx, maxx, miny, maxy,
advance), ...]. None is entered in the list for each unrecognized
character.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.font.Font.get_italic">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">check if the text will be rendered italic</span></div>
<div class="line"><span class="signature">get_italic() -&gt; bool</span></div>
</div>
<p>Return True when the font italic rendering mode is enabled.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.font.Font.get_linesize">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">get the line space of the font text</span></div>
<div class="line"><span class="signature">get_linesize() -&gt; int</span></div>
</div>
<p>Return the height in pixels for a line of text with the font. When
rendering multiple lines of text this is the recommended amount of space
between lines.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.font.Font.get_height">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">get the height of the font</span></div>
<div class="line"><span class="signature">get_height() -&gt; int</span></div>
</div>
<p>Return the height in pixels of the actual rendered text. This is the
average size for each glyph in the font.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.font.Font.get_ascent">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">get the ascent of the font</span></div>
<div class="line"><span class="signature">get_ascent() -&gt; int</span></div>
</div>
<p>Return the height in pixels for the font ascent. The ascent is the number
of pixels from the font baseline to the top of the font.</p>
</dd></dl>

<dl class="definition method">
<dt class="title" id="pygame.font.Font.get_descent">
<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>
<dd><div class="line-block">
<div class="line"><span class="summaryline">get the descent of the font</span></div>
<div class="line"><span class="signature">get_descent() -&gt; int</span></div>
</div>
<p>Return the height in pixels for the font descent. The descent is the
number of pixels from the font baseline to the bottom of the font.</p>
</dd></dl>

</dd></dl>

</dd></dl>

</div>

  </div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="freetype.html" title="pygame.freetype"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="examples.html" title="pygame.examples"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">Pygame v1.9.2 documentation</a> &raquo;</li>
    <script type="text/javascript" src="jquery.plugin.docscomments.js"></script>

      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2011, Pygame Developers.
    </div>
  </body>
</html>