Issue 19 in freetype-py: Face.get_kerning does not seem to work on Max OSX

20 views
Skip to first unread message

freet...@googlecode.com

unread,
Sep 29, 2011, 9:07:15 AM9/29/11
to Nicolas...@inria.fr
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

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

freet...@googlecode.com

unread,
Sep 29, 2011, 9:23:14 AM9/29/11
to Nicolas...@inria.fr
Updates:
Status: Invalid

Comment #1 on issue 19 by Nicolas.Rougier: Face.get_kerning does not seem

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.

freet...@googlecode.com

unread,
Sep 29, 2011, 12:39:37 PM9/29/11
to Nicolas...@inria.fr

Comment #2 on issue 19 by dankri...@gmail.com: Face.get_kerning does not

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


freet...@googlecode.com

unread,
Sep 29, 2011, 2:28:05 PM9/29/11
to Nicolas...@inria.fr

Comment #3 on issue 19 by Nicolas.Rougier: Face.get_kerning does not seem

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)

Reply all
Reply to author
Forward
0 new messages