File: al_get_glyph_advance.3

package info (click to toggle)
allegro5 2%3A5.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 23,032 kB
  • sloc: ansic: 120,340; cpp: 15,707; objc: 4,805; python: 2,915; java: 2,195; sh: 887; xml: 86; makefile: 49; perl: 37; pascal: 24
file content (94 lines) | stat: -rw-r--r-- 3,386 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
.TH "al_get_glyph_advance" "3" "" "Allegro reference manual" ""
.SH NAME
.PP
al_get_glyph_advance \- Allegro 5 API
.SH SYNOPSIS
.IP
.nf
\f[C]
#include\ <allegro5/allegro_font.h>

int\ al_get_glyph_advance(const\ ALLEGRO_FONT\ *f,\ int\ codepoint1,\ int\ codepoint2)
\f[]
.fi
.SH DESCRIPTION
.PP
This function returns by how much the x position should be advanced for
left to right text drawing when the glyph that corresponds to codepoint1
has been drawn, and the glyph that corresponds to codepoint2 will be the
next to be drawn.
This takes into consideration the horizontal advance width of the glyph
that corresponds with codepoint1 as well as the kerning between the
glyphs of codepoint1 and codepoint2.
.PP
Kerning is the process of adjusting the spacing between glyphs in a
font, to obtain a more visually pleasing result.
Kerning adjusts the space between two individual glyphs with an offset
determined by the author of the font.
.PP
If you pass ALLEGRO_NO_KERNING as codepoint1 then al_get_glyph_advance
will return 0.
this can be useful when drawing the first character of a string in a
loop.
.PP
Pass ALLEGRO_NO_KERNING as codepoint2 to get the horizontal advance
width of the glyph that corresponds to codepoint1 without taking any
kerning into consideration.
This can be used, for example, when drawing the last character of a
string in a loop.
.PP
This function will return zero if the glyph of codepoint1 is not present
in the \f[C]font\f[].
If the glyph of codepoint2 is not present in the font, the horizontal
advance width of the glyph that corresponds to codepoint1 without taking
any kerning into consideration is returned.
.PP
When drawing a string one glyph at the time from the left to the right
with kerning, the x position of the glyph should be incremented by the
result of al_get_glyph_advance(3) applied to the previous glyph drawn
and the next glyph to draw.
.PP
Note that the return value of this function is a recommended advance for
optimal readability for left to right text determined by the author of
the font.
However, if you like, you may want to draw the glyphs of the font
narrower or wider to each other than what al_get_glyph_advance(3)
returns for style or effect.
.PP
In the figure below is an example of what the result of
al_get_glyph_advance may be like for two glypphs \f[C]A\f[] and
\f[C]l\f[] of the same font that has kerning for the "Al" pair, without
and with the ALLEGRO_NO_KERNING flag.
.IP
.nf
\f[C]
al_get_glyph_advance(font,\ \[aq]A\[aq],\ \[aq]l\[aq])
\ \ \ \ \ ___|___\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 
\ \ \ \ /\ \ \ \ \ \ \ \\\ \ 
\ \ \ \ \-\-\-\-\-\-\-\-\-\-\-\-\-\ \ \ \ \ \ \ \ \ \ \ \ 
\ \ \ \ \ \ \ \ /\\\ \ \ \-|\ \ 
\ \ \ \ \ \ \ /\ \ \\\ \ \ |
\ \ \ \ \ \ /____\\\ \ |
\ \ \ \ \ /\ \ \ \ \ \ \\\ |
\ \ \ \ /\ \ \ \ \ \ \ \ \\\ \\_\ \ \ \ \ \ \ \ \ \ \ \ \ 
\ \ \ \ \-\-\-\-\-\-\-\-\-\-\-\-\-
\ \ \ \ 
\ \ \ \ 
al_get_glyph_advance(font,\ \[aq]A\[aq],\ ALLEGRO_NO_KERNING)
\ \ \ \ \ ____|____
\ \ \ \ /\ \ \ \ \ \ \ \ \ \\\ \ 
\ \ \ \ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
\ \ \ \ \ \ \ \ /\\\ \ \ \ \ \-|\ \ 
\ \ \ \ \ \ \ /\ \ \\\ \ \ \ \ |
\ \ \ \ \ \ /____\\\ \ \ \ |
\ \ \ \ \ /\ \ \ \ \ \ \\\ \ \ |
\ \ \ \ /\ \ \ \ \ \ \ \ \\\ \ \ \\_\ \ \ \ \ \ \ \ \ \ \ \ \ 
\ \ \ \ \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
\f[]
.fi
.SH SINCE
.PP
5.1.12
.SH SEE ALSO
.PP
al_draw_glyph(3), al_get_glyph_width(3), al_get_glyph_dimensions(3).