]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Load kerning again blub/font-codepage-replacement
authorWolfgang (Blub) Bumiller <blub@speed.at>
Thu, 3 Nov 2011 12:16:55 +0000 (13:16 +0100)
committerWolfgang Bumiller <wolfgang.linux@bumiller.com>
Mon, 30 Apr 2012 18:59:35 +0000 (20:59 +0200)
ft2.c

diff --git a/ft2.c b/ft2.c
index d8529416ce192492044b7521c17ca465cd147408..b7a13d4f73abcc0cceac74d4803ff0ac5bb730fa 100644 (file)
--- a/ft2.c
+++ b/ft2.c
@@ -589,6 +589,7 @@ qboolean Font_LoadFont(const char *name, dp_font_t *dpfnt)
                                // Bogus size check needs to be done here already
                        } else
                                ++count;
+                       // FIXME: KERNING:
                }
                if (!count)
                {
@@ -633,6 +634,30 @@ qboolean Font_LoadFont(const char *name, dp_font_t *dpfnt)
                        fsize->glyphSize = CeilPowerOf2(fsize->glyphSize);
                */
                fsize->intSize = -1;
+               if (ft2->has_kerning)
+               {
+                       Uchar l, r;
+                       FT_Vector kernvec;
+                       for (l = 0; l < 256; ++l)
+                       {
+                               for (r = 0; r < 256; ++r)
+                               {
+                                       FT_ULong ul, ur;
+                                       ul = qFT_Get_Char_Index((FT_Face)ft2->face, l);
+                                       ur = qFT_Get_Char_Index((FT_Face)ft2->face, r);
+                                       if (qFT_Get_Kerning((FT_Face)ft2->face, ul, ur, FT_KERNING_DEFAULT, &kernvec))
+                                       {
+                                               fsize->kerning.kerning[l][r][0] = 0;
+                                               fsize->kerning.kerning[l][r][1] = 0;
+                                       }
+                                       else
+                                       {
+                                               fsize->kerning.kerning[l][r][0] = Font_SnapTo((kernvec.x / 64.0) / fsize->size, 1 / fsize->size);
+                                               fsize->kerning.kerning[l][r][1] = Font_SnapTo((kernvec.y / 64.0) / fsize->size, 1 / fsize->size);
+                                       }
+                               }
+                       }
+               }
        }
        if (!count)
        {