]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - ft2.c
reducing error output in font loading (use developer != 0 to re-enable)
[xonotic/darkplaces.git] / ft2.c
diff --git a/ft2.c b/ft2.c
index 431555610126ef1f543da54261022488fc64a727..54b0985ea74ec970245a6bae07ddbf3a9b44b1f1 100644 (file)
--- a/ft2.c
+++ b/ft2.c
@@ -169,10 +169,8 @@ qboolean Font_OpenLibrary (void)
 {
        const char* dllnames [] =
        {
-#if defined(WIN64)
-               #error path for freetype 2 dll
-#elif defined(WIN32)
-               #error path for freetype 2 dll
+#if defined(WIN32)
+               "freetype6.dll",
 #elif defined(MACOSX)
                "libfreetype.dylib",
 #else
@@ -290,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)
@@ -349,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)
@@ -376,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)
@@ -396,7 +410,7 @@ qboolean Font_LoadFont(const char *name, dp_font_t *dpfnt)
 static qboolean Font_LoadFile(const char *name, int _face, ft2_font_t *font)
 {
        size_t namelen;
-       char filename[PATH_MAX];
+       char filename[MAX_QPATH];
        int status;
        size_t i;
        unsigned char *data;
@@ -601,7 +615,7 @@ int Font_IndexForSize(ft2_font_t *font, float _fsize, float *outw, float *outh)
                                break;
                }
        }
-       if (value <= r_font_size_snapping.integer)
+       if (value <= r_font_size_snapping.value)
        {
                if (outw && outh)
                {
@@ -735,7 +749,7 @@ void Font_UnloadFont(ft2_font_t *font)
 
 static qboolean Font_LoadMap(ft2_font_t *font, ft2_font_map_t *mapstart, Uchar _ch, ft2_font_map_t **outmap)
 {
-       char map_identifier[PATH_MAX];
+       char map_identifier[MAX_QPATH];
        unsigned long mapidx = _ch / FONT_CHARS_PER_MAP;
        unsigned char *data;
        FT_ULong ch, mapch;
@@ -912,7 +926,8 @@ static qboolean Font_LoadMap(ft2_font_t *font, ft2_font_map_t *mapstart, Uchar _
                        if (status)
                        {
                                //Con_Printf("failed to load glyph %lu for %s\n", glyphIndex, font->name);
-                               Con_Printf("failed to load glyph for char %lx from font %s\n", (unsigned long)ch, font->name);
+                               if (developer.integer)
+                                       Con_Printf("failed to load glyph for char %lx from font %s\n", (unsigned long)ch, font->name);
                                continue;
                        }
                }