1al_grab_font_from_bitmap(3)Library Functions Manualal_grab_font_from_bitmap(3)
2
3
4

NAME

6       al_grab_font_from_bitmap
7

SYNOPSIS

9              #include <allegro5/allegro_font.h>
10
11              ALLEGRO_FONT *al_grab_font_from_bitmap(ALLEGRO_BITMAP *bmp,
12                 int ranges_n, 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       In the above illustration, the dot is for pixels having the  background
31       color.  It is determined by the color of the top left pixel in the bit‐
32       map.  There should be a border of at least 1 pixel with this  color  to
33       the bitmap edge and between all glyphs.
34
35       Each  glyph  is  inside  a rectangle of pixels not containing the back‐
36       ground color.  The height of all glyph rectangles should be  the  same,
37       but the width can vary.
38
39       The placement of the rectangles does not matter, except that glyphs are
40       scanned from left to right and top to bottom to match them to the spec‐
41       ified unicode codepoints.
42
43       The glyphs will simply be drawn using al_draw_bitmap(3), so usually you
44       will want the rectangles filled with full transparency and  the  glyphs
45       drawn in opaque white.
46
47       Examples:
48
49              int ranges[] = {32, 126};
50              al_grab_font_from_bitmap(bitmap, 1, ranges)
51
52              int ranges[] = {
53                  0x0020, 0x007F,  /* ASCII */
54                  0x00A1, 0x00FF,  /* Latin 1 */
55                  0x0100, 0x017F,  /* Extended-A */
56                  0x20AC, 0x20AC}; /* Euro */
57              al_grab_font_from_bitmap(bitmap, 4, ranges)
58
59       The  first example will grab glyphs for the 95 standard printable ASCII
60       characters, beginning with the space character (32) and ending with the
61       tilde character (126).  The second example will map the first 96 glyphs
62       found in the bitmap to ASCII range, the next 95 glyphs to Latin 1,  the
63       next  128  glyphs to Extended-A, and the last glyph to the Euro charac‐
64       ter.  (This is just the characters found in the Allegro 4 font.)
65

SEE ALSO

67       al_load_bitmap(3), al_grab_font_from_bitmap(3)
68
69
70
71Allegro reference manual                           al_grab_font_from_bitmap(3)
Impressum