1al_grab_font_from_bitmap(3)                        al_grab_font_from_bitmap(3)
2
3
4

NAME

6       al_grab_font_from_bitmap - Allegro 5 API
7

SYNOPSIS

9              #include <allegro5/allegro_font.h>
10
11              ALLEGRO_FONT *al_grab_font_from_bitmap(ALLEGRO_BITMAP *bmp,
12                 int ranges_n, const int ranges[])
13

DESCRIPTION

15       Creates  a  new font from an Allegro bitmap.  You can delete the bitmap
16       after the function returns as the font will contain a copy for itself.
17
18       Parameters:
19
20       • bmp: The bitmap with the glyphs drawn onto it
21
22       • n: Number of unicode ranges in the bitmap.
23
24       • ranges: `n' pairs of first and last unicode point to  map  glyphs  to
25         for each range.
26
27       The  bitmap format is as in the following example, which contains three
28       glyphs for 1, 2 and 3.
29
30              .............
31              . 1 .222.333.
32              . 1 .  2.  3.
33              . 1 .222.333.
34              . 1 .2  .  3.
35              . 1 .222.333.
36              .............
37
38       In the above illustration, the dot is for pixels having the  background
39       color.  It is determined by the color of the top left pixel in the bit‐
40       map.  There should be a border of at least 1 pixel with this  color  to
41       the bitmap edge and between all glyphs.
42
43       Each  glyph  is  inside  a rectangle of pixels not containing the back‐
44       ground color.  The height of all glyph rectangles should be  the  same,
45       but the width can vary.
46
47       The placement of the rectangles does not matter, except that glyphs are
48       scanned from left to right and top to bottom to match them to the spec‐
49       ified unicode codepoints.
50
51       The glyphs will simply be drawn using al_draw_bitmap(3), so usually you
52       will want the rectangles filled with full transparency and  the  glyphs
53       drawn in opaque white.
54
55       Examples:
56
57              int ranges[] = {32, 126};
58              al_grab_font_from_bitmap(bitmap, 1, ranges)
59
60              int ranges[] = {
61                  0x0020, 0x007F,  /* ASCII */
62                  0x00A1, 0x00FF,  /* Latin 1 */
63                  0x0100, 0x017F,  /* Extended-A */
64                  0x20AC, 0x20AC}; /* Euro */
65              al_grab_font_from_bitmap(bitmap, 4, ranges)
66
67       The  first example will grab glyphs for the 95 standard printable ASCII
68       characters, beginning with the space character (32) and ending with the
69       tilde character (126).  The second example will map the first 96 glyphs
70       found in the bitmap to ASCII range, the next 95 glyphs to Latin 1,  the
71       next  128  glyphs to Extended-A, and the last glyph to the Euro charac‐
72       ter.  (This is just the characters found in the Allegro 4 font.)
73

SEE ALSO

75       al_load_bitmap(3), al_grab_font_from_bitmap(3)
76
77
78
79Allegro reference manual                           al_grab_font_from_bitmap(3)
Impressum