]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
freetype: "loadfont" now uses virtual pixels, not real pixels, for font sizes, to...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 26 Dec 2009 18:59:15 +0000 (18:59 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 26 Dec 2009 18:59:15 +0000 (18:59 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9700 d7cf8633-e32d-0410-b094-e92efae38249

ft2.c
gl_draw.c

diff --git a/ft2.c b/ft2.c
index 7ed5ae52c5b3f0339c4fd1e070bab01ba08279f5..df1daa38e7b47761b12703169c534932274d83c0 100644 (file)
--- a/ft2.c
+++ b/ft2.c
@@ -288,6 +288,22 @@ qboolean Font_Attach(ft2_font_t *font, ft2_attachment_t *attachment)
        return true;
 }
 
+static float Font_VirtualToRealSize(float sz)
+{
+       int vh, vw, si;
+       float sn;
+       if(sz < 0)
+               return sz;
+       vw = ((vid.width > 0) ? vid.width : vid_width.value);
+       vh = ((vid.height > 0) ? vid.height : vid_height.value);
+       // now try to scale to our actual size:
+       sn = sz * vh / vid_conheight.value;
+       si = (int)sn;
+       if ( sn - (float)si >= 0.5 )
+               ++si;
+       return si;
+}
+
 static qboolean Font_LoadFile(const char *name, int _face, ft2_font_t *font);
 static qboolean Font_LoadSize(ft2_font_t *font, float size, qboolean no_texture, qboolean no_kerning);
 qboolean Font_LoadFont(const char *name, dp_font_t *dpfnt)
@@ -347,7 +363,7 @@ qboolean Font_LoadFont(const char *name, dp_font_t *dpfnt)
                count = 0;
                for (s = 0; s < MAX_FONT_SIZES; ++s)
                {
-                       if (Font_LoadSize(fb, dpfnt->req_sizes[s], true, false))
+                       if (Font_LoadSize(fb, Font_VirtualToRealSize(dpfnt->req_sizes[s]), true, false))
                                ++count;
                }
                if (!count)
@@ -374,7 +390,7 @@ qboolean Font_LoadFont(const char *name, dp_font_t *dpfnt)
        count = 0;
        for (s = 0; s < MAX_FONT_SIZES; ++s)
        {
-               if (Font_LoadSize(ft2, dpfnt->req_sizes[s], false, false))
+               if (Font_LoadSize(ft2, Font_VirtualToRealSize(dpfnt->req_sizes[s]), false, false))
                        ++count;
        }
        if (!count)
index 1f749284e3f4fdb04c1bc0cfbdd4a9465f328dac..e6f6c5f78eef3eff436749266663222967d8f4b0 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -681,9 +681,9 @@ static float snap_to_pixel_y(float y, float roundUpAt)
 static void LoadFont_f(void)
 {
        dp_font_t *f;
-       int i, si;
-       float sz, sn;
+       int i;
        const char *filelist, *c, *cm;
+       float sz;
        char mainfont[MAX_QPATH];
 
        if(Cmd_Argc() < 2)
@@ -777,21 +777,7 @@ static void LoadFont_f(void)
                        sz = atof(Cmd_Argv(i+3));
                        if (IS_NAN(sz)) // do not use crap sizes
                                continue;
-                       // now try to scale to our actual size:
-                       if (vid.width > 0)
-                               sn = snap_to_pixel_y(sz, 0.5);
-                       else
-                       {
-                               sn = sz * vid_height.value / vid_conheight.value;
-                               si = (int)sn;
-                               if ( sn - (float)si >= 0.5 )
-                                       ++si;
-                               sn = si * vid_conheight.value / vid_height.value;
-                       }
-                       if (!IS_NAN(sn))
-                               f->req_sizes[i] = sn;
-                       else
-                               f->req_sizes[i] = sz;
+                       f->req_sizes[i] = sz;
                }
        }
        LoadFont(true, mainfont, f);