New issue 19 by dankri...@gmail.com: Face.get_kerning does not seem to work
on Max OSX
http://code.google.com/p/freetype-py/issues/detail?id=19
Maybe I'm doing this wrong but I need to extract character pair kerning
information but my tests always return (0,0)?
from freetype import *
face = Face('/Library/Fonts/Arial.ttf')
face.load_char('V')
face.load_char('A')
v = face.get_kerning( face.get_char_index('V'), face.get_char_index('A') )
# This is always zero even for fonts that "visually" have kerning
v.x == 0
I'm using version 0.3.3 on Snow Leopard (with whatever freetype that ships
with the OS).
Is this the correct way to retrive kerning offsets?
Is there a way of just retrieving all Kerning info for a font without
looping through every single character pair combination?
Cheers
Dan
Comment #1 on issue 19 by Nicolas.Rougier: Face.get_kerning does not seem
to work on Max OSX
http://code.google.com/p/freetype-py/issues/detail?id=19
I think you forgot to set the face size.
Here is a minimal example on how to use kerning:
face = Face('/Library/Fonts/Arial.ttf')
face.set_char_size( 48*64 )
print face.get_kerning('A','V').x
(No need to actually load the glyph)
Concerning your last question, I do not know if there exist a way to
retrieve kerning at once. Most probably you have to iterate through each
combination.
Thanks Nicolas!
I would have forgot if I had actually known about that in the first place :)
Now I need to understand what that value is?
From what I can glean, to convert this "26.6 format" to pixels I divide by
64.0?
i.e:
xPixelOffset = face.get_kerning('A','V').x / 64.0
You can specify how to get kerning:
# FT_KERNING_DEFAULT
# Return scaled and grid-fitted kerning distances (value is 0).
#
# FT_KERNING_UNFITTED
# Return scaled but un-grid-fitted kerning distances.
#
# FT_KERNING_UNSCALED
# Return the kerning vector in original font units.
(This does not appear in documentation of the function but is present in
the ft_enums.py file as comment)