1al_get_glyph_advance(3)                                al_get_glyph_advance(3)
2
3
4

NAME

6       al_get_glyph_advance - Allegro 5 API
7

SYNOPSIS

9              #include <allegro5/allegro_font.h>
10
11              int al_get_glyph_advance(const ALLEGRO_FONT *f, int codepoint1, int codepoint2)
12

DESCRIPTION

14       This function returns by how much the x position should be advanced for
15       left to right text drawing when the glyph  that  corresponds  to  code‐
16       point1  has  been  drawn,  and the glyph that corresponds to codepoint2
17       will be the next to be drawn.  This takes into consideration the  hori‐
18       zontal  advance  width of the glyph that corresponds with codepoint1 as
19       well as the kerning between the glyphs of codepoint1 and codepoint2.
20
21       Kerning is the process of adjusting the spacing  between  glyphs  in  a
22       font,  to  obtain a more visually pleasing result.  Kerning adjusts the
23       space between two individual glyphs with an offset  determined  by  the
24       author of the font.
25
26       If  you pass ALLEGRO_NO_KERNING as codepoint1 then al_get_glyph_advance
27       will return 0.  this can be useful when drawing the first character  of
28       a string in a loop.
29
30       Pass  ALLEGRO_NO_KERNING  as  codepoint2  to get the horizontal advance
31       width of the glyph that corresponds to codepoint1  without  taking  any
32       kerning  into consideration.  This can be used, for example, when draw‐
33       ing the last character of a string in a loop.
34
35       This function will return zero  if  the  glyph  of  codepoint1  is  not
36       present  in the font.  If the glyph of codepoint2 is not present in the
37       font, the horizontal advance width of the  glyph  that  corresponds  to
38       codepoint1 without taking any kerning into consideration is returned.
39
40       When  drawing a string one glyph at the time from the left to the right
41       with kerning, the x position of the glyph should be incremented by  the
42       result  of  al_get_glyph_advance(3) applied to the previous glyph drawn
43       and the next glyph to draw.
44
45       Note that the return value of this function is  a  recommended  advance
46       for optimal readability for left to right text determined by the author
47       of the font.  However, if you like, you may want to draw the glyphs  of
48       the  font  narrower  or  wider to each other than what al_get_glyph_ad‐
49       vance(3) returns for style or effect.
50
51       In  the  figure  below  is  an  example   of   what   the   result   of
52       al_get_glyph_advance  may  be  like for two glypphs A and l of the same
53       font that has kerning for the “Al” pair, without  and  with  the  ALLE‐
54       GRO_NO_KERNING flag.
55
56              al_get_glyph_advance(font, 'A', 'l')
57                   ___|___
58                  /       \
59                  -------------
60                      /\   -|
61                     /  \   |
62                    /____\  |
63                   /      \ |
64                  /        \ \_
65                  -------------
66
67
68              al_get_glyph_advance(font, 'A', ALLEGRO_NO_KERNING)
69                   ____|____
70                  /         \
71                  ---------------
72                      /\     -|
73                     /  \     |
74                    /____\    |
75                   /      \   |
76                  /        \   \_
77                  ---------------
78

SINCE

80       5.1.12
81

SEE ALSO

83       al_draw_glyph(3), al_get_glyph_width(3), al_get_glyph_dimensions(3).
84
85
86
87Allegro reference manual                               al_get_glyph_advance(3)
Impressum