~ubuntu-branches/ubuntu/gutsy/pygame/gutsy

« back to all changes in this revision

Viewing changes to docs/ref/Font.html

  • Committer: Bazaar Package Importer
  • Author(s): Ed Boraas
  • Date: 2002-02-20 06:39:24 UTC
  • Revision ID: james.westby@ubuntu.com-20020220063924-amlzj7tqkeods4eq
Tags: upstream-1.4
ImportĀ upstreamĀ versionĀ 1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
<title>Font</title>
 
3
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>
 
4
 
 
5
 
 
6
<table cellspacing=3 width=100%><tr><td bgcolor=#00000>
 
7
<table width=100%><tr><td bgcolor=c2fc20 align=center>
 
8
    <a href=http://www.pygame.org>
 
9
    <img src=../pygame_tiny.gif border=0 width=200 height=60></a><br>
 
10
    <b>pygame&nbsp;&nbsp;&nbsp;documentation</b>
 
11
</td><td bgcolor=6aee28 align=center valign=top width=100%>
 
12
 
 
13
        ||&nbsp;
 
14
        <a href=http://www.pygame.org>Home</a> &nbsp;||&nbsp;
 
15
        <a href=../index.html>Help Contents</a> &nbsp;||
 
16
        <br>&nbsp;<br>
 
17
 
 
18
|| <a href=pygame.html>pygame</a> || 
 
19
<a href=pygame_cdrom.html>cdrom</a> || 
 
20
<a href=pygame_constants.html>constants</a> || 
 
21
<a href=pygame_display.html>display</a> || 
 
22
<a href=pygame_draw.html>draw</a> || 
 
23
<a href=pygame_event.html>event</a> ||<br>
 
24
|| <a href=pygame_font.html>font</a> || 
 
25
<a href=pygame_image.html>image</a> || 
 
26
<a href=pygame_joystick.html>joystick</a> || 
 
27
<a href=pygame_key.html>key</a> || 
 
28
<a href=pygame_mixer.html>mixer</a> || 
 
29
<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
 
30
|| <a href=pygame_mouse.html>mouse</a> || 
 
31
<a href=pygame_movie.html>movie</a> || 
 
32
<a href=pygame_surfarray.html>surfarray</a> || 
 
33
<a href=pygame_time.html>time</a> || 
 
34
<a href=pygame_transform.html>transform</a> ||<br>
 
35
&nbsp;<br>|| <a href=CD.html>CD</a> || 
 
36
<a href=Channel.html>Channel</a> || 
 
37
<a href=Clock.html>Clock</a> || 
 
38
<a href=Font.html>Font</a> || 
 
39
<a href=Joystick.html>Joystick</a> || 
 
40
<a href=Movie.html>Movie</a> ||<br>
 
41
|| <a href=Rect.html>Rect</a> || 
 
42
<a href=Sound.html>Sound</a> || 
 
43
<a href=Surface.html>Surface</a> ||<br>
 
44
&nbsp;<br>|| <a href=pygame_cursors.html>cursors</a> || 
 
45
<a href=pygame_sprite.html>sprite</a> || 
 
46
<a href=pygame_version.html>version</a> ||<br>
 
47
 
 
48
 
 
49
</td></tr></table></td></tr></table>
 
50
<br>
 
51
<h2 align=center>Font</h2>
 
52
The font object is created only from <a href=pygame_font.html#Font>pygame.font.Font()</a>. Once a
 
53
font is created it's size and TTF file cannot be changed. The
 
54
Font objects are mainly used to <a href=#render>render()</a> text into a new Surface.
 
55
The Font objects also have a few states that can be set with
 
56
<a href=#set_underline>set_underline(bool)</a>, <a href=#set_bold>set_bold(bool)</a>, <a href=#set_italic>set_italic(bool)</a>. Each of
 
57
these functions contains an equivalent get_XXX() routine to find
 
58
the current state. There are also many routines to query the
 
59
dimensions of the text. The rendering functions work with both
 
60
normal python strings, as well as with unicode strings.
 
61
 
 
62
<hr>
 
63
 
 
64
<table>
 
65
<tr><td><a href=#get_ascent>get_ascent</a></td><td> -
 
66
gets the font ascent</td></tr>
 
67
 
 
68
 
 
69
<tr><td><a href=#get_bold>get_bold</a></td><td> -
 
70
status of the bold attribute</td></tr>
 
71
 
 
72
 
 
73
<tr><td><a href=#get_descent>get_descent</a></td><td> -
 
74
gets the font descent</td></tr>
 
75
 
 
76
 
 
77
<tr><td><a href=#get_height>get_height</a></td><td> -
 
78
average height of font glyph</td></tr>
 
79
 
 
80
 
 
81
<tr><td><a href=#get_italic>get_italic</a></td><td> -
 
82
status of the italic attribute</td></tr>
 
83
 
 
84
 
 
85
<tr><td><a href=#get_linesize>get_linesize</a></td><td> -
 
86
gets the font recommended linesize</td></tr>
 
87
 
 
88
 
 
89
<tr><td><a href=#get_underline>get_underline</a></td><td> -
 
90
status of the underline attribute</td></tr>
 
91
 
 
92
 
 
93
<tr><td><a href=#render>render</a></td><td> -
 
94
render text to a new image</td></tr>
 
95
 
 
96
 
 
97
<tr><td><a href=#set_bold>set_bold</a></td><td> -
 
98
assign the bold attribute</td></tr>
 
99
 
 
100
 
 
101
<tr><td><a href=#set_italic>set_italic</a></td><td> -
 
102
assign the italic attribute</td></tr>
 
103
 
 
104
 
 
105
<tr><td><a href=#set_underline>set_underline</a></td><td> -
 
106
assign the underline attribute</td></tr>
 
107
 
 
108
 
 
109
<tr><td><a href=#size>size</a></td><td> -
 
110
size of rendered text</td></tr>
 
111
 
 
112
 
 
113
</table>
 
114
 
 
115
<hr>
 
116
 
 
117
<a name=get_ascent><font size=+2><b>get_ascent
 
118
</b></font><br><font size=+1><tt>
 
119
Font.get_ascent() -> int
 
120
</tt></font><ul>
 
121
Returns the ascent for the font. The ascent is the number of
 
122
pixels from the font baseline to the top of the font.
 
123
</ul><br>&nbsp;<br>
 
124
 
 
125
<a name=get_bold><font size=+2><b>get_bold
 
126
</b></font><br><font size=+1><tt>
 
127
Font.get_bold() -> bool
 
128
</tt></font><ul>
 
129
Get the current status of the font's bold attribute
 
130
</ul><br>&nbsp;<br>
 
131
 
 
132
<a name=get_descent><font size=+2><b>get_descent
 
133
</b></font><br><font size=+1><tt>
 
134
Font.get_descent() -> int
 
135
</tt></font><ul>
 
136
Returns the descent for the font. The descent is the number of
 
137
pixels from the font baseline to the bottom of the font.
 
138
</ul><br>&nbsp;<br>
 
139
 
 
140
<a name=get_height><font size=+2><b>get_height
 
141
</b></font><br><font size=+1><tt>
 
142
Font.get_height() -> int
 
143
</tt></font><ul>
 
144
Returns the average size of each glyph in the font.
 
145
</ul><br>&nbsp;<br>
 
146
 
 
147
<a name=get_italic><font size=+2><b>get_italic
 
148
</b></font><br><font size=+1><tt>
 
149
Font.get_italic() -> bool
 
150
</tt></font><ul>
 
151
Get the current status of the font's italic attribute
 
152
</ul><br>&nbsp;<br>
 
153
 
 
154
<a name=get_linesize><font size=+2><b>get_linesize
 
155
</b></font><br><font size=+1><tt>
 
156
Font.get_linesize() -> int
 
157
</tt></font><ul>
 
158
Returns the linesize for the font. Each font comes with it's own
 
159
recommendation for the spacing number of pixels between each line
 
160
of the font.
 
161
</ul><br>&nbsp;<br>
 
162
 
 
163
<a name=get_underline><font size=+2><b>get_underline
 
164
</b></font><br><font size=+1><tt>
 
165
Font.get_underline() -> bool
 
166
</tt></font><ul>
 
167
Get the current status of the font's underline attribute
 
168
</ul><br>&nbsp;<br>
 
169
 
 
170
<a name=render><font size=+2><b>render
 
171
</b></font><br><font size=+1><tt>
 
172
Font.render(text, antialias, fore_RGBA, [back_RGBA]) -> Surface
 
173
</tt></font><ul>
 
174
Render the given text onto a new image surface. The given text
 
175
can be standard python text or unicode. Antialiasing will smooth
 
176
the edges of the font for a much cleaner look. The foreground
 
177
and background color are both RGBA, the alpha component is ignored
 
178
if given. If the background color is omitted, the text will have a
 
179
transparent background.
 
180
<br>&nbsp;<br>
 
181
Note that font rendering is not thread safe, therefore only one
 
182
thread can render text at any given time.
 
183
<br>&nbsp;<br>
 
184
Also, rendering smooth text with underlines will crash with SDL_ttf
 
185
less that version 2.0, be careful.
 
186
</ul><br>&nbsp;<br>
 
187
 
 
188
<a name=set_bold><font size=+2><b>set_bold
 
189
</b></font><br><font size=+1><tt>
 
190
Font.set_bold(bool) -> None
 
191
</tt></font><ul>
 
192
Enables or disables the bold attribute for the font. Making the
 
193
font bold does not work as well as you expect.
 
194
</ul><br>&nbsp;<br>
 
195
 
 
196
<a name=set_italic><font size=+2><b>set_italic
 
197
</b></font><br><font size=+1><tt>
 
198
Font.set_italic(bool) -> None
 
199
</tt></font><ul>
 
200
Enables or disables the italic attribute for the font.
 
201
</ul><br>&nbsp;<br>
 
202
 
 
203
<a name=set_underline><font size=+2><b>set_underline
 
204
</b></font><br><font size=+1><tt>
 
205
Font.set_underline(bool) -> None
 
206
</tt></font><ul>
 
207
Enables or disables the underline attribute for the font.
 
208
</ul><br>&nbsp;<br>
 
209
 
 
210
<a name=size><font size=+2><b>size
 
211
</b></font><br><font size=+1><tt>
 
212
Font.size(text) -> width, height
 
213
</tt></font><ul>
 
214
Computes the rendered size of the given text. The text can be
 
215
standard python text or unicode. Changing the bold and italic
 
216
attributes can change the size of the rendered text.
 
217
</ul><br>&nbsp;<br>
 
218
 
 
219
 
 
220
<hr>
 
221
</body></html>