Revision: 70
Author: Nicolas.Rougier
Date: Wed Jun 13 23:27:59 2012
Log: Fix kerning computation in texture font
http://code.google.com/p/freetype-py/source/detail?r=70
Modified:
/trunk/examples/subpixel-positioning.py
/trunk/examples/texture_font.py
=======================================
--- /trunk/examples/subpixel-positioning.py Thu Aug 18 00:40:24 2011
+++ /trunk/examples/subpixel-positioning.py Wed Jun 13 23:27:59 2012
@@ -85,7 +85,7 @@
for i,charcode in enumerate(text):
glyph = font[charcode]
- kerning = glyph.get_kerning(prev)/64.0
+ kerning = glyph.get_kerning(prev)
x0 = pen[0] + glyph.offset[0] + kerning
dx = x0-int(x0)
x0 = int(x0)
=======================================
--- /trunk/examples/texture_font.py Mon Jun 4 23:43:01 2012
+++ /trunk/examples/texture_font.py Wed Jun 13 23:27:59 2012
@@ -354,12 +354,14 @@
# Generate kerning
for g in self.glyphs.values():
- kerning = face.get_kerning(g.charcode, charcode,
mode=FT_KERNING_UNSCALED)
+ # 64 * 64 because of 26.6 encoding AND the transform
matrix used
+ # in texture_font_load_face (hres = 64)
+ kerning = face.get_kerning(g.charcode, charcode,
mode=FT_KERNING_UNFITTED)
if kerning.x != 0:
- glyph.kerning[g.charcode] = kerning.x
- kerning = face.get_kerning(charcode, g.charcode,
mode=FT_KERNING_UNSCALED)
+ glyph.kerning[g.charcode] = kerning.x/(64.0*64.0)
+ kerning = face.get_kerning(charcode, g.charcode,
mode=FT_KERNING_UNFITTED)
if kerning.x != 0:
- g.kerning[charcode] = kerning.x
+ g.kerning[charcode] = kerning.x/(64.0*64.0)
# High resolution advance.x calculation
# gindex = face.get_char_index( charcode )