kern = GetKerningPair(a$, b$[, encoding])
a$
and b$
if they were drawn next to each other.
Kerning is often used to reduce spaces between two characters. For example,
if a "j" character is drawn next to an "i" character, the "j" is usually
moved some pixels to the left so that its underhang appears below the "i"
which makes the text look more smooth. The kerning value returned by this
function is specified in pixels. A negative kerning value means a move to
the left, while a positive kerning value moves to the right.
The optional argument encoding
can be used to specify the character encoding
inside a$
and b$
. This defaults to the default text library character encoding
as set by SetDefaultEncoding(). See SetDefaultEncoding for details.
Note there must be only one character in a$
and b$
for GetKerningPair()
to
work correctly.
a$
and b$
SetFont(#SANS, 72) SetFontStyle(#ANTIALIAS) kern = GetKerningPair("W", "a")The code above computes the kerning value for characters "W" and "a" using the inbuilt sans-serif font in size 72. It will return -3 which means that the "a" character is moved 3 pixels towards the "W" character.