Name
GetKerningPair -- return kerning setting for two adjacent characters (V5.0)
Synopsis
kern = GetKerningPair(a$, b$[, encoding])
Function
This function computes the kerning value that would be applied to the space between the two characters 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.

Inputs
a$
character one
b$
character two
encoding
optional: character encoding used by the strings (defaults to the text library encoding specified in the last call to SetDefaultEncoding())
Results
kern
kerning value for a$ and b$
Example
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.

Show TOC