]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - ft2.c
bugfix recent font additions
[xonotic/darkplaces.git] / ft2.c
diff --git a/ft2.c b/ft2.c
index ca21fa4b17ec6664cd18d6280d4617a5b09f87df..6b9152c17116b9aa70a32053e35c637e478e383a 100644 (file)
--- a/ft2.c
+++ b/ft2.c
@@ -150,7 +150,7 @@ typedef struct
        unsigned char gausstable[2*POSTPROCESS_MAXRADIUS+1];
 }
 font_postprocess_t;
-static font_postprocess_t pp = {};
+static font_postprocess_t pp;
 
 /*
 ====================
@@ -251,12 +251,12 @@ void font_start(void)
 void font_shutdown(void)
 {
        int i;
-       for (i = 0; i < MAX_FONTS; ++i)
+       for (i = 0; i < dp_fonts.maxsize; ++i)
        {
-               if (dp_fonts[i].ft2)
+               if (dp_fonts.f[i].ft2)
                {
-                       Font_UnloadFont(dp_fonts[i].ft2);
-                       dp_fonts[i].ft2 = NULL;
+                       Font_UnloadFont(dp_fonts.f[i].ft2);
+                       dp_fonts.f[i].ft2 = NULL;
                }
        }
        Font_CloseLibrary();
@@ -273,6 +273,7 @@ void Font_Init(void)
        Cvar_RegisterVariable(&r_font_size_snapping);
        Cvar_RegisterVariable(&r_font_kerning);
        Cvar_RegisterVariable(&developer_font);
+
        // let's open it at startup already
        Font_OpenLibrary();
 }
@@ -312,11 +313,13 @@ qboolean Font_Attach(ft2_font_t *font, ft2_attachment_t *attachment)
 
 float Font_VirtualToRealSize(float sz)
 {
-       int vh, vw, si;
+       int vh;
+       //int vw;
+       int si;
        float sn;
        if(sz < 0)
                return sz;
-       vw = ((vid.width > 0) ? vid.width : vid_width.value);
+       //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;
@@ -461,14 +464,22 @@ static qboolean Font_LoadFile(const char *name, int _face, ft2_settings_t *setti
 
        namelen = strlen(name);
 
-       memcpy(filename, name, namelen);
-       memcpy(filename + namelen, ".ttf", 5);
+       // try load direct file
+       memcpy(filename, name, namelen+1);
        data = FS_LoadFile(filename, font_mempool, false, &datasize);
+       // try load .ttf
+       if (!data)
+       {
+               memcpy(filename + namelen, ".ttf", 5);
+               data = FS_LoadFile(filename, font_mempool, false, &datasize);
+       }
+       // try load .otf
        if (!data)
        {
                memcpy(filename + namelen, ".otf", 5);
                data = FS_LoadFile(filename, font_mempool, false, &datasize);
        }
+       // try load .pfb/afm
        if (!data)
        {
                ft2_attachment_t afm;
@@ -485,13 +496,12 @@ static qboolean Font_LoadFile(const char *name, int _face, ft2_settings_t *setti
                                Font_Attach(font, &afm);
                }
        }
-
        if (!data)
        {
                // FS_LoadFile being not-quiet should print an error :)
                return false;
        }
-       Con_Printf("Loading font %s face %i...\n", filename, _face);
+       Con_DPrintf("Loading font %s face %i...\n", filename, _face);
 
        status = qFT_New_Memory_Face(font_ft2lib, (FT_Bytes)data, datasize, _face, (FT_Face*)&font->face);
        if (status && _face != 0)
@@ -529,13 +539,10 @@ static qboolean Font_LoadFile(const char *name, int _face, ft2_settings_t *setti
 
 void Font_Postprocess_Update(ft2_font_t *fnt, int bpp, int w, int h)
 {
-       qboolean need_gauss, need_circle;
        int needed, x, y;
        float gausstable[2*POSTPROCESS_MAXRADIUS+1];
-       if(!pp.buf || pp.blur != fnt->settings->blur || pp.shadowz != fnt->settings->shadowz)
-               need_gauss = true;
-       if(!pp.buf || pp.outline != fnt->settings->outline || pp.shadowx != fnt->settings->shadowx || pp.shadowy != fnt->settings->shadowy)
-               need_circle = true;
+       qboolean need_gauss  = (!pp.buf || pp.blur != fnt->settings->blur || pp.shadowz != fnt->settings->shadowz);
+       qboolean need_circle = (!pp.buf || pp.outline != fnt->settings->outline || pp.shadowx != fnt->settings->shadowx || pp.shadowy != fnt->settings->shadowy);
        pp.blur = fnt->settings->blur;
        pp.outline = fnt->settings->outline;
        pp.shadowx = fnt->settings->shadowx;