File: font.html

package info (click to toggle)
allegro5 2%3A5.0.10-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 14,856 kB
  • ctags: 15,948
  • sloc: ansic: 87,540; cpp: 9,693; objc: 3,491; python: 2,057; sh: 829; makefile: 93; perl: 37; pascal: 24
file content (386 lines) | stat: -rw-r--r-- 27,515 bytes parent folder | download
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
<!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" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title>Font addons</title>
  <style type="text/css">code{white-space: pre;}</style>
  <link rel="stylesheet" href="pandoc.css" type="text/css" />
  <script type="text/javascript" src="autosuggest.js"></script>
  <script type="text/javascript" src="search_index.js"></script>
</head>
<body>
<div class="sidebar">

<div>
<ul>
<li><a href="index.html"><strong>Contents</strong></a></li>
<li><a href="config.html">Configuration files</a></li>
<li><a href="display.html">Display</a></li>
<li><a href="events.html">Events</a></li>
<li><a href="file.html">File I/O</a></li>
<li><a href="fshook.html">Filesystem</a></li>
<li><a href="fixed.html">Fixed point math</a></li>
<li><a href="fullscreen_mode.html">Fullscreen modes</a></li>
<li><a href="graphics.html">Graphics</a></li>
<li><a href="joystick.html">Joystick</a></li>
<li><a href="keyboard.html">Keyboard</a></li>
<li><a href="memory.html">Memory</a></li>
<li><a href="monitor.html">Monitor</a></li>
<li><a href="mouse.html">Mouse</a></li>
<li><a href="path.html">Path</a></li>
<li><a href="state.html">State</a></li>
<li><a href="system.html">System</a></li>
<li><a href="threads.html">Threads</a></li>
<li><a href="time.html">Time</a></li>
<li><a href="timer.html">Timer</a></li>
<li><a href="transformations.html">Transformations</a></li>
<li><a href="utf8.html">UTF-8</a></li>
<li><a href="misc.html">Miscellaneous</a></li>
<li><a href="platform.html">Platform-specific</a></li>
<li><a href="direct3d.html">Direct3D</a></li>
<li><a href="opengl.html">OpenGL</a></li>
</ul>
<!-- The preceding blank line forces pandoc to terminate the list -->
</div>

<div>
<ul>
<li><a href="index.html#addons"><strong>Addons</strong></a></li>
<li><a href="audio.html">Audio addon</a></li>
<li><a href="acodec.html">Audio codecs</a></li>
<li><a href="color.html">Color addon</a></li>
<li><a href="font.html">Font addons</a></li>
<li><a href="image.html">Image I/O addon</a></li>
<li><a href="main.html">Main addon</a></li>
<li><a href="memfile.html">Memfile addon</a></li>
<li><a href="native_dialog.html">Native dialogs addon</a></li>
<li><a href="physfs.html">PhysicsFS addon</a></li>
<li><a href="primitives.html">Primitives addon</a></li>
</ul>
<!-- The preceding blank line forces pandoc to terminate the list -->
</div>

<div>
<ul>
<li><a href="index_all.html"><strong>Index</strong></a></li>
</ul>
<!-- The preceding blank line forces pandoc to terminate the list -->
</div>

<div class="searchbox">
<script type="text/javascript">
function on_search(index, control) {
    // Note to self: the less-than sign must NOT converted to an entity!
    // SCRIPT elements are special.  The HTML validator gives bad advice.
    for (i = 0; i < search_index.length; i++) {
        if (search_index[i] == control.keywords[index]) {
            break;
        }
    }
    location.href = search_urls[i];
}
</script>
Search<br/> <input type="text" name="q" id="q" size="15" autocomplete="off"/><br/>
<script type="text/javascript"> new autosuggest("q", search_index, null, on_search); </script>
</div>

</div>

<div class="content">



<div id="header">
<h1 class="title">Font addons</h1>
</div>
<div id="TOC">
<ul>
<li><a href="#general-font-routines">General font routines</a><ul>
<li><a href="#allegro_font">ALLEGRO_FONT</a></li>
<li><a href="#al_init_font_addon">al_init_font_addon</a></li>
<li><a href="#al_shutdown_font_addon">al_shutdown_font_addon</a></li>
<li><a href="#al_load_font">al_load_font</a></li>
<li><a href="#al_destroy_font">al_destroy_font</a></li>
<li><a href="#al_register_font_loader">al_register_font_loader</a></li>
<li><a href="#al_get_font_line_height">al_get_font_line_height</a></li>
<li><a href="#al_get_font_ascent">al_get_font_ascent</a></li>
<li><a href="#al_get_font_descent">al_get_font_descent</a></li>
<li><a href="#al_get_text_width">al_get_text_width</a></li>
<li><a href="#al_get_ustr_width">al_get_ustr_width</a></li>
<li><a href="#al_draw_text">al_draw_text</a></li>
<li><a href="#al_draw_ustr">al_draw_ustr</a></li>
<li><a href="#al_draw_justified_text">al_draw_justified_text</a></li>
<li><a href="#al_draw_justified_ustr">al_draw_justified_ustr</a></li>
<li><a href="#al_draw_textf">al_draw_textf</a></li>
<li><a href="#al_draw_justified_textf">al_draw_justified_textf</a></li>
<li><a href="#al_get_text_dimensions">al_get_text_dimensions</a></li>
<li><a href="#al_get_ustr_dimensions">al_get_ustr_dimensions</a></li>
<li><a href="#al_get_allegro_font_version">al_get_allegro_font_version</a></li>
</ul></li>
<li><a href="#bitmap-fonts">Bitmap fonts</a><ul>
<li><a href="#al_grab_font_from_bitmap">al_grab_font_from_bitmap</a></li>
<li><a href="#al_load_bitmap_font">al_load_bitmap_font</a></li>
<li><a href="#al_create_builtin_font">al_create_builtin_font</a></li>
</ul></li>
<li><a href="#ttf-fonts">TTF fonts</a><ul>
<li><a href="#al_init_ttf_addon">al_init_ttf_addon</a></li>
<li><a href="#al_shutdown_ttf_addon">al_shutdown_ttf_addon</a></li>
<li><a href="#al_load_ttf_font">al_load_ttf_font</a></li>
<li><a href="#al_load_ttf_font_f">al_load_ttf_font_f</a></li>
<li><a href="#al_load_ttf_font_stretch">al_load_ttf_font_stretch</a></li>
<li><a href="#al_load_ttf_font_stretch_f">al_load_ttf_font_stretch_f</a></li>
<li><a href="#al_get_allegro_ttf_version">al_get_allegro_ttf_version</a></li>
</ul></li>
</ul>
</div>
<p>These functions are declared in the following header file. Link with allegro_font.</p>
<pre><code>#include &lt;allegro5/allegro_font.h&gt;</code></pre>
<h1 id="general-font-routines"><a href="#general-font-routines">General font routines</a></h1>
<h2 id="allegro_font"><a href="#allegro_font">ALLEGRO_FONT</a></h2>
<pre><code>typedef struct ALLEGRO_FONT ALLEGRO_FONT;</code></pre>
<p>A handle identifying any kind of font. Usually you will create it with <a href="font.html#al_load_font">al_load_font</a> which supports loading all kinds of TrueType fonts supported by the FreeType library. If you instead pass the filename of a bitmap file, it will be loaded with <a href="graphics.html#al_load_bitmap">al_load_bitmap</a> and a font in Allegro's bitmap font format will be created from it with <a href="font.html#al_grab_font_from_bitmap">al_grab_font_from_bitmap</a>.</p>
<h2 id="al_init_font_addon"><a href="#al_init_font_addon">al_init_font_addon</a></h2>
<pre><code>void al_init_font_addon(void)</code></pre>
<p>Initialise the font addon.</p>
<p>Note that if you intend to load bitmap fonts, you will need to initialise allegro_image separately (unless you are using another library to load images).</p>
<p>See also: <a href="image.html#al_init_image_addon">al_init_image_addon</a>, <a href="font.html#al_init_ttf_addon">al_init_ttf_addon</a>, <a href="font.html#al_shutdown_font_addon">al_shutdown_font_addon</a></p>
<h2 id="al_shutdown_font_addon"><a href="#al_shutdown_font_addon">al_shutdown_font_addon</a></h2>
<pre><code>void al_shutdown_font_addon(void)</code></pre>
<p>Shut down the font addon. This is done automatically at program exit, but can be called any time the user wishes as well.</p>
<p>See also: <a href="font.html#al_init_font_addon">al_init_font_addon</a></p>
<h2 id="al_load_font"><a href="#al_load_font">al_load_font</a></h2>
<pre><code>ALLEGRO_FONT *al_load_font(char const *filename, int size, int flags)</code></pre>
<p>Loads a font from disk. This will use <a href="font.html#al_load_bitmap_font">al_load_bitmap_font</a> if you pass the name of a known bitmap format, or else <a href="font.html#al_load_ttf_font">al_load_ttf_font</a>.</p>
<p>Bitmap and TTF fonts are affected by the current bitmap flags at the time the font is loaded.</p>
<p>See also: <a href="font.html#al_destroy_font">al_destroy_font</a>, <a href="font.html#al_init_font_addon">al_init_font_addon</a>, <a href="font.html#al_register_font_loader">al_register_font_loader</a></p>
<h2 id="al_destroy_font"><a href="#al_destroy_font">al_destroy_font</a></h2>
<pre><code>void al_destroy_font(ALLEGRO_FONT *f)</code></pre>
<p>Frees the memory being used by a font structure. Does nothing if passed NULL.</p>
<p>See also: <a href="font.html#al_load_font">al_load_font</a></p>
<h2 id="al_register_font_loader"><a href="#al_register_font_loader">al_register_font_loader</a></h2>
<pre><code>bool al_register_font_loader(char const *extension,
   ALLEGRO_FONT *(*load_font)(char const *filename, int size, int flags))</code></pre>
<p>Informs Allegro of a new font file type, telling it how to load files of this format.</p>
<p>The extension should include the leading dot ('.') character. It will be matched case-insensitively.</p>
<p>The <code>load_font</code> argument may be NULL to unregister an entry.</p>
<p>Returns true on success, false on error. Returns false if unregistering an entry that doesn't exist.</p>
<p>See also: <a href="font.html#al_init_font_addon">al_init_font_addon</a></p>
<h2 id="al_get_font_line_height"><a href="#al_get_font_line_height">al_get_font_line_height</a></h2>
<pre><code>int al_get_font_line_height(const ALLEGRO_FONT *f)</code></pre>
<p>Returns the usual height of a line of text in the specified font. For bitmap fonts this is simply the height of all glyph bitmaps. For truetype fonts it is whatever the font file specifies. In particular, some special glyphs may be higher than the height returned here.</p>
<p>If the X is the position you specify to draw text, the meaning of ascent and descent and the line height is like in the figure below.</p>
<pre><code>X------------------------
    /\         |        |
   /  \        |        |
  /____\       ascent   |
 /      \      |        |
/        \     |        height
----------------        |
               |        |
               descent  |
               |        |
-------------------------</code></pre>
<p>See also: <a href="font.html#al_get_text_width">al_get_text_width</a>, <a href="font.html#al_get_text_dimensions">al_get_text_dimensions</a></p>
<h2 id="al_get_font_ascent"><a href="#al_get_font_ascent">al_get_font_ascent</a></h2>
<pre><code>int al_get_font_ascent(const ALLEGRO_FONT *f)</code></pre>
<p>Returns the ascent of the specified font.</p>
<p>See also: <a href="font.html#al_get_font_descent">al_get_font_descent</a>, <a href="font.html#al_get_font_line_height">al_get_font_line_height</a></p>
<h2 id="al_get_font_descent"><a href="#al_get_font_descent">al_get_font_descent</a></h2>
<pre><code>int al_get_font_descent(const ALLEGRO_FONT *f)</code></pre>
<p>Returns the descent of the specified font.</p>
<p>See also: <a href="font.html#al_get_font_ascent">al_get_font_ascent</a>, <a href="font.html#al_get_font_line_height">al_get_font_line_height</a></p>
<h2 id="al_get_text_width"><a href="#al_get_text_width">al_get_text_width</a></h2>
<pre><code>int al_get_text_width(const ALLEGRO_FONT *f, const char *str)</code></pre>
<p>Calculates the length of a string in a particular font, in pixels.</p>
<p>See also: <a href="font.html#al_get_ustr_width">al_get_ustr_width</a>, <a href="font.html#al_get_font_line_height">al_get_font_line_height</a>, <a href="font.html#al_get_text_dimensions">al_get_text_dimensions</a></p>
<h2 id="al_get_ustr_width"><a href="#al_get_ustr_width">al_get_ustr_width</a></h2>
<pre><code>int al_get_ustr_width(const ALLEGRO_FONT *f, ALLEGRO_USTR const *ustr)</code></pre>
<p>Like <a href="font.html#al_get_text_width">al_get_text_width</a> but expects an ALLEGRO_USTR.</p>
<p>See also: <a href="font.html#al_get_text_width">al_get_text_width</a>, <a href="font.html#al_get_ustr_dimensions">al_get_ustr_dimensions</a></p>
<h2 id="al_draw_text"><a href="#al_draw_text">al_draw_text</a></h2>
<pre><code>void al_draw_text(const ALLEGRO_FONT *font,
   ALLEGRO_COLOR color, float x, float y, int flags,
   char const *text) </code></pre>
<p>Writes the NUL-terminated string <code>text</code> onto the target bitmap at position <code>x</code>, <code>y</code>, using the specified <code>font</code>.</p>
<p>The <code>flags</code> parameter can be 0 or one of the following flags:</p>
<ul>
<li>ALLEGRO_ALIGN_LEFT - Draw the text left-aligned (same as 0).</li>
<li>ALLEGRO_ALIGN_CENTRE - Draw the text centered around the given position.</li>
<li>ALLEGRO_ALIGN_RIGHT - Draw the text right-aligned to the given position.</li>
</ul>
<p>It can also be combined with this flag:</p>
<ul>
<li>ALLEGRO_ALIGN_INTEGER - Always draw text aligned to an integer pixel position. This is formerly the default behaviour. Since: 5.0.8, 5.1.4</li>
</ul>
<p>See also: <a href="font.html#al_draw_ustr">al_draw_ustr</a>, <a href="font.html#al_draw_textf">al_draw_textf</a>, <a href="font.html#al_draw_justified_text">al_draw_justified_text</a></p>
<h2 id="al_draw_ustr"><a href="#al_draw_ustr">al_draw_ustr</a></h2>
<pre><code>void al_draw_ustr(const ALLEGRO_FONT *font,
   ALLEGRO_COLOR color, float x, float y, int flags,
   const ALLEGRO_USTR *ustr) </code></pre>
<p>Like <a href="font.html#al_draw_text">al_draw_text</a>, except the text is passed as an ALLEGRO_USTR instead of a NUL-terminated char array.</p>
<p>See also: <a href="font.html#al_draw_text">al_draw_text</a>, <a href="font.html#al_draw_justified_ustr">al_draw_justified_ustr</a></p>
<h2 id="al_draw_justified_text"><a href="#al_draw_justified_text">al_draw_justified_text</a></h2>
<pre><code>void al_draw_justified_text(const ALLEGRO_FONT *font,
   ALLEGRO_COLOR color, float x1, float x2,
   float y, float diff, int flags, const char *text)</code></pre>
<p>Like <a href="font.html#al_draw_text">al_draw_text</a>, but justifies the string to the region x1-x2.</p>
<p>The <em>diff</em> parameter is the maximum amount of horizontal space to allow between words. If justisfying the text would exceed <em>diff</em> pixels, or the string contains less than two words, then the string will be drawn left aligned.</p>
<p>The <code>flags</code> parameter can be 0 or one of the following flags:</p>
<ul>
<li>ALLEGRO_ALIGN_INTEGER - Draw text aligned to integer pixel positions. Since: 5.0.8, 5.1.5</li>
</ul>
<p>See also: <a href="font.html#al_draw_justified_textf">al_draw_justified_textf</a>, <a href="font.html#al_draw_justified_ustr">al_draw_justified_ustr</a></p>
<h2 id="al_draw_justified_ustr"><a href="#al_draw_justified_ustr">al_draw_justified_ustr</a></h2>
<pre><code>void al_draw_justified_ustr(const ALLEGRO_FONT *font,
   ALLEGRO_COLOR color, float x1, float x2,
   float y, float diff, int flags, const ALLEGRO_USTR *ustr)</code></pre>
<p>Like <a href="font.html#al_draw_justified_text">al_draw_justified_text</a>, except the text is passed as an ALLEGRO_USTR instead of a NUL-terminated char array.</p>
<p>See also: <a href="font.html#al_draw_justified_text">al_draw_justified_text</a>, <a href="font.html#al_draw_justified_textf">al_draw_justified_textf</a>.</p>
<h2 id="al_draw_textf"><a href="#al_draw_textf">al_draw_textf</a></h2>
<pre><code>void al_draw_textf(const ALLEGRO_FONT *font, ALLEGRO_COLOR color,
   float x, float y, int flags,
   const char *format, ...)</code></pre>
<p>Formatted text output, using a printf() style format string. All parameters have the same meaning as with <a href="font.html#al_draw_text">al_draw_text</a> otherwise.</p>
<p>See also: <a href="font.html#al_draw_text">al_draw_text</a>, <a href="font.html#al_draw_ustr">al_draw_ustr</a></p>
<h2 id="al_draw_justified_textf"><a href="#al_draw_justified_textf">al_draw_justified_textf</a></h2>
<pre><code>void al_draw_justified_textf(const ALLEGRO_FONT *f,
   ALLEGRO_COLOR color, float x1, float x2, float y,
   float diff, int flags, const char *format, ...)</code></pre>
<p>Formatted text output, using a printf() style format string. All parameters have the same meaning as with <a href="font.html#al_draw_justified_text">al_draw_justified_text</a> otherwise.</p>
<p>See also: <a href="font.html#al_draw_justified_text">al_draw_justified_text</a>, <a href="font.html#al_draw_justified_ustr">al_draw_justified_ustr</a>.</p>
<h2 id="al_get_text_dimensions"><a href="#al_get_text_dimensions">al_get_text_dimensions</a></h2>
<pre><code>void al_get_text_dimensions(const ALLEGRO_FONT *f,
   char const *text,
   int *bbx, int *bby, int *bbw, int *bbh)</code></pre>
<p>Sometimes, the <a href="font.html#al_get_text_width">al_get_text_width</a> and <a href="font.html#al_get_font_line_height">al_get_font_line_height</a> functions are not enough for exact text placement, so this function returns some additional information.</p>
<p>Returned variables (all in pixel):</p>
<ul>
<li>x, y - Offset to upper left corner of bounding box.</li>
<li>w, h - Dimensions of bounding box.</li>
</ul>
<p>Note that glyphs may go to the left and upwards of the X, in which case x and y will have negative values.</p>
<p>See also: <a href="font.html#al_get_text_width">al_get_text_width</a>, <a href="font.html#al_get_font_line_height">al_get_font_line_height</a>, <a href="font.html#al_get_ustr_dimensions">al_get_ustr_dimensions</a></p>
<h2 id="al_get_ustr_dimensions"><a href="#al_get_ustr_dimensions">al_get_ustr_dimensions</a></h2>
<pre><code>void al_get_ustr_dimensions(const ALLEGRO_FONT *f,
   ALLEGRO_USTR const *ustr,
   int *bbx, int *bby, int *bbw, int *bbh)</code></pre>
<p>Sometimes, the <a href="font.html#al_get_ustr_width">al_get_ustr_width</a> and <a href="font.html#al_get_font_line_height">al_get_font_line_height</a> functions are not enough for exact text placement, so this function returns some additional information.</p>
<p>See also: <a href="font.html#al_get_text_dimensions">al_get_text_dimensions</a></p>
<h2 id="al_get_allegro_font_version"><a href="#al_get_allegro_font_version">al_get_allegro_font_version</a></h2>
<pre><code>uint32_t al_get_allegro_font_version(void)</code></pre>
<p>Returns the (compiled) version of the addon, in the same format as <a href="system.html#al_get_allegro_version">al_get_allegro_version</a>.</p>
<h1 id="bitmap-fonts"><a href="#bitmap-fonts">Bitmap fonts</a></h1>
<h2 id="al_grab_font_from_bitmap"><a href="#al_grab_font_from_bitmap">al_grab_font_from_bitmap</a></h2>
<pre><code>ALLEGRO_FONT *al_grab_font_from_bitmap(ALLEGRO_BITMAP *bmp,
   int ranges_n, const int ranges[])</code></pre>
<p>Creates a new font from an Allegro bitmap. You can delete the bitmap after the function returns as the font will contain a copy for itself.</p>
<p>Parameters:</p>
<ul>
<li>bmp: The bitmap with the glyphs drawn onto it</li>
<li>n: Number of unicode ranges in the bitmap.</li>
<li>ranges: 'n' pairs of first and last unicode point to map glyphs to for each range.</li>
</ul>
<p>The bitmap format is as in the following example, which contains three glyphs for 1, 2 and 3.</p>
<pre><code>.............
. 1 .222.333.
. 1 .  2.  3.
. 1 .222.333.
. 1 .2  .  3.
. 1 .222.333.
.............</code></pre>
<p>In the above illustration, the dot is for pixels having the background color. It is determined by the color of the top left pixel in the bitmap. There should be a border of at least 1 pixel with this color to the bitmap edge and between all glyphs.</p>
<p>Each glyph is inside a rectangle of pixels not containing the background color. The height of all glyph rectangles should be the same, but the width can vary.</p>
<p>The placement of the rectangles does not matter, except that glyphs are scanned from left to right and top to bottom to match them to the specified unicode codepoints.</p>
<p>The glyphs will simply be drawn using <a href="graphics.html#al_draw_bitmap">al_draw_bitmap</a>, so usually you will want the rectangles filled with full transparency and the glyphs drawn in opaque white.</p>
<p>Examples:</p>
<pre><code>int ranges[] = {32, 126};
al_grab_font_from_bitmap(bitmap, 1, ranges)

int ranges[] = {
    0x0020, 0x007F,  /* ASCII */
    0x00A1, 0x00FF,  /* Latin 1 */
    0x0100, 0x017F,  /* Extended-A */
    0x20AC, 0x20AC}; /* Euro */
al_grab_font_from_bitmap(bitmap, 4, ranges)</code></pre>
<p>The first example will grab glyphs for the 95 standard printable ASCII characters, beginning with the space character (32) and ending with the tilde character (126). The second example will map the first 96 glyphs found in the bitmap to ASCII range, the next 95 glyphs to Latin 1, the next 128 glyphs to Extended-A, and the last glyph to the Euro character. (This is just the characters found in the Allegro 4 font.)</p>
<p>See also: <a href="graphics.html#al_load_bitmap">al_load_bitmap</a>, <a href="font.html#al_grab_font_from_bitmap">al_grab_font_from_bitmap</a></p>
<h2 id="al_load_bitmap_font"><a href="#al_load_bitmap_font">al_load_bitmap_font</a></h2>
<pre><code>ALLEGRO_FONT *al_load_bitmap_font(const char *fname)</code></pre>
<p>Load a bitmap font from. It does this by first calling <a href="graphics.html#al_load_bitmap">al_load_bitmap</a> and then <a href="font.html#al_grab_font_from_bitmap">al_grab_font_from_bitmap</a>. If you want to for example load an old A4 font, you could load the bitmap yourself, then call <a href="graphics.html#al_convert_mask_to_alpha">al_convert_mask_to_alpha</a> on it and only then pass it to <a href="font.html#al_grab_font_from_bitmap">al_grab_font_from_bitmap</a>.</p>
<h2 id="al_create_builtin_font"><a href="#al_create_builtin_font">al_create_builtin_font</a></h2>
<pre><code>ALLEGRO_FONT *al_create_builtin_font(void)</code></pre>
<p>Creates a monochrome bitmap font (8x8 pixels per character).</p>
<p>This font is primarily intended to be used for displaying information in environments or during early runtime states where no external font data is available or loaded (e.g. for debugging).</p>
<p>The builtin font contains the following unicode character ranges:</p>
<pre><code>0x0020 to 0x007F (ASCII)
0x00A1 to 0x00FF (Latin 1)
0x0100 to 0x017F (Extended A)
0x20AC to 0x20AC (euro currency symbol)</code></pre>
<p>Returns NULL on an error.</p>
<p>The font memory must be freed the same way as for any other font, using <a href="font.html#al_destroy_font">al_destroy_font</a>.</p>
<p>Since: 5.0.8, 5.1.3</p>
<p>See also: <a href="font.html#al_load_bitmap_font">al_load_bitmap_font</a>, <a href="font.html#al_destroy_font">al_destroy_font</a></p>
<h1 id="ttf-fonts"><a href="#ttf-fonts">TTF fonts</a></h1>
<p>These functions are declared in the following header file. Link with allegro_ttf.</p>
<pre><code>#include &lt;allegro5/allegro_ttf.h&gt;</code></pre>
<h2 id="al_init_ttf_addon"><a href="#al_init_ttf_addon">al_init_ttf_addon</a></h2>
<pre><code>bool al_init_ttf_addon(void)</code></pre>
<p>Call this after <a href="font.html#al_init_font_addon">al_init_font_addon</a> to make <a href="font.html#al_load_font">al_load_font</a> recognize &quot;.ttf&quot; and other formats supported by <a href="font.html#al_load_ttf_font">al_load_ttf_font</a>.</p>
<p>Returns true on success, false on failure.</p>
<h2 id="al_shutdown_ttf_addon"><a href="#al_shutdown_ttf_addon">al_shutdown_ttf_addon</a></h2>
<pre><code>void al_shutdown_ttf_addon(void)</code></pre>
<p>Unloads the ttf addon again. You normally don't need to call this.</p>
<h2 id="al_load_ttf_font"><a href="#al_load_ttf_font">al_load_ttf_font</a></h2>
<pre><code>ALLEGRO_FONT *al_load_ttf_font(char const *filename, int size, int flags)</code></pre>
<p>Loads a TrueType font from a file using the FreeType library. Quoting from the FreeType FAQ this means support for many different font formats:</p>
<p><em>TrueType, OpenType, Type1, CID, CFF, Windows FON/FNT, X11 PCF, and others</em></p>
<p>The <em>size</em> parameter determines the size the font will be rendered at, specified in pixels. The standard font size is measured in <em>units per EM</em>, if you instead want to specify the size as the total height of glyphs in pixels, pass it as a negative value.</p>
<blockquote>
<p><em>Note:</em> If you want to display text at multiple sizes, load the font multiple times with different size parameters.</p>
</blockquote>
<p>The following flags are supported:</p>
<ul>
<li><p>ALLEGRO_TTF_NO_KERNING - Do not use any kerning even if the font file supports it.</p></li>
<li><p>ALLEGRO_TTF_MONOCHROME - Load as a monochrome font (which means no anti-aliasing of the font is done).</p></li>
<li><p>ALLEGRO_TTF_NO_AUTOHINT - Disable the Auto Hinter which is enabled by default in newer versions of FreeType. Since: 5.0.6, 5.1.2</p></li>
</ul>
<p>See also: <a href="font.html#al_init_ttf_addon">al_init_ttf_addon</a>, <a href="font.html#al_load_ttf_font_f">al_load_ttf_font_f</a></p>
<h2 id="al_load_ttf_font_f"><a href="#al_load_ttf_font_f">al_load_ttf_font_f</a></h2>
<pre><code>ALLEGRO_FONT *al_load_ttf_font_f(ALLEGRO_FILE *file,
    char const *filename, int size, int flags)</code></pre>
<p>Like <a href="font.html#al_load_ttf_font">al_load_ttf_font</a>, but the font is read from the file handle. The filename is only used to find possible additional files next to a font file.</p>
<blockquote>
<p><em>Note:</em> The file handle is owned by the returned ALLEGRO_FONT object and must not be freed by the caller, as FreeType expects to be able to read from it at a later time.</p>
</blockquote>
<h2 id="al_load_ttf_font_stretch"><a href="#al_load_ttf_font_stretch">al_load_ttf_font_stretch</a></h2>
<pre><code>ALLEGRO_FONT *al_load_ttf_font_stretch(char const *filename, int w, int h,
    int flags)</code></pre>
<p>Like <a href="font.html#al_load_ttf_font">al_load_ttf_font</a>, except it takes separate width and height parameters instead of a single size parameter.</p>
<p>If the height is a positive value, and the width zero or positive, then font will be stretched according to those parameters. The width must not be negative if the height is positive.</p>
<p>As with <a href="font.html#al_load_ttf_font">al_load_ttf_font</a>, the height may be a negative value to specify the total height in pixels. Then the width must also be a negative value, or zero.</p>
<p>The behaviour is undefined the height is positive while width is negative, or if the height is negative while the width is positive.</p>
<p>Since: 5.0.6, 5.1.0</p>
<p>See also: <a href="font.html#al_load_ttf_font">al_load_ttf_font</a>, <a href="font.html#al_load_ttf_font_stretch_f">al_load_ttf_font_stretch_f</a></p>
<h2 id="al_load_ttf_font_stretch_f"><a href="#al_load_ttf_font_stretch_f">al_load_ttf_font_stretch_f</a></h2>
<pre><code>ALLEGRO_FONT *al_load_ttf_font_stretch_f(ALLEGRO_FILE *file,
    char const *filename, int w, int h, int flags)</code></pre>
<p>Like <a href="font.html#al_load_ttf_font_stretch">al_load_ttf_font_stretch</a>, but the font is read from the file handle. The filename is only used to find possible additional files next to a font file.</p>
<blockquote>
<p><em>Note:</em> The file handle is owned by the returned ALLEGRO_FONT object and must not be freed by the caller, as FreeType expects to be able to read from it at a later time.</p>
</blockquote>
<p>Since: 5.0.6, 5.1.0</p>
<p>See also: <a href="font.html#al_load_ttf_font_stretch">al_load_ttf_font_stretch</a></p>
<h2 id="al_get_allegro_ttf_version"><a href="#al_get_allegro_ttf_version">al_get_allegro_ttf_version</a></h2>
<pre><code>uint32_t al_get_allegro_ttf_version(void)</code></pre>
<p>Returns the (compiled) version of the addon, in the same format as <a href="system.html#al_get_allegro_version">al_get_allegro_version</a>.</p>
<p class="timestamp">
Allegro version 5.0.10
 - Last updated: 2013-06-16 03:32:13 UTC
</p>
</div>


</body>
</html>