]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - ft2.c
Refactor game/mod cvar defaults
[xonotic/darkplaces.git] / ft2.c
diff --git a/ft2.c b/ft2.c
index 0b1f9dcc111abc0288ad03f8bf101290d805c8e8..c7fe3ace1f46896eb31a9b0c0c6025514b8405b6 100644 (file)
--- a/ft2.c
+++ b/ft2.c
@@ -53,7 +53,6 @@ CVars introduced with the freetype extension
 */
 
 cvar_t r_font_disable_freetype = {CF_CLIENT | CF_ARCHIVE, "r_font_disable_freetype", "0", "disable freetype support for fonts entirely"};
-cvar_t r_font_use_alpha_textures = {CF_CLIENT | CF_ARCHIVE, "r_font_use_alpha_textures", "0", "[deprecated, not effective] use alpha-textures for font rendering, this should save memory"};
 cvar_t r_font_size_snapping = {CF_CLIENT | CF_ARCHIVE, "r_font_size_snapping", "1", "stick to good looking font sizes whenever possible - bad when the mod doesn't support it!"};
 cvar_t r_font_kerning = {CF_CLIENT | CF_ARCHIVE, "r_font_kerning", "1", "Use kerning if available"};
 cvar_t r_font_diskcache = {CF_CLIENT | CF_ARCHIVE, "r_font_diskcache", "0", "[deprecated, not effective] save font textures to disk for future loading rather than generating them every time"};
@@ -289,7 +288,7 @@ static const unsigned char *fontfilecache_LoadFile(const char *path, qbool quiet
                for(i = 0; i < MAX_FONTFILES; ++i)
                        if(fontfiles[i].refcount <= 0)
                        {
-                               strlcpy(fontfiles[i].path, path, sizeof(fontfiles[i].path));
+                               dp_strlcpy(fontfiles[i].path, path, sizeof(fontfiles[i].path));
                                fontfiles[i].len = *filesizepointer;
                                fontfiles[i].buf = buf;
                                fontfiles[i].refcount = 1;
@@ -445,7 +444,6 @@ void Font_Init(void)
 {
        Cvar_RegisterVariable(&r_font_nonpoweroftwo);
        Cvar_RegisterVariable(&r_font_disable_freetype);
-       Cvar_RegisterVariable(&r_font_use_alpha_textures);
        Cvar_RegisterVariable(&r_font_size_snapping);
        Cvar_RegisterVariable(&r_font_kerning);
        Cvar_RegisterVariable(&r_font_diskcache);
@@ -504,7 +502,7 @@ float Font_VirtualToRealSize(float sz)
        if(sz < 0)
                return sz;
        //vw = ((vid.width > 0) ? vid.width : vid_width.value);
-       vh = ((vid.height > 0) ? vid.height : vid_height.value);
+       vh = ((vid.mode.height > 0) ? vid.mode.height : vid_height.value);
        // now try to scale to our actual size:
        sn = sz * vh / vid_conheight.value;
        si = (int)sn;
@@ -549,7 +547,7 @@ qbool Font_LoadFont(const char *name, dp_font_t *dpfnt)
                        Mem_Free(ft2);
                        return false;
                }
-               strlcpy(ft2->name, name, sizeof(ft2->name));
+               dp_strlcpy(ft2->name, name, sizeof(ft2->name));
                ft2->image_font = true;
                ft2->has_kerning = false;
        }
@@ -726,7 +724,7 @@ static qbool Font_LoadFile(const char *name, int _face, ft2_settings_t *settings
                        Con_Printf(CON_ERROR "Failed to add attachment %u to %s\n", (unsigned)i, font->name);
        }
 
-       strlcpy(font->name, name, sizeof(font->name));
+       dp_strlcpy(font->name, name, sizeof(font->name));
        font->image_font = false;
        font->has_kerning = !!(((FT_Face)(font->face))->face_flags & FT_FACE_FLAG_KERNING);
        return true;
@@ -1008,11 +1006,11 @@ int Font_IndexForSize(ft2_font_t *font, float _fsize, float *outw, float *outh)
        float fsize_x, fsize_y;
        ft2_font_map_t **maps = font->font_maps;
 
-       fsize_x = fsize_y = _fsize * vid.height / vid_conheight.value;
+       fsize_x = fsize_y = _fsize * vid.mode.height / vid_conheight.value;
        if(outw && *outw)
-               fsize_x = *outw * vid.width / vid_conwidth.value;
+               fsize_x = *outw * vid.mode.width / vid_conwidth.value;
        if(outh && *outh)
-               fsize_y = *outh * vid.height / vid_conheight.value;
+               fsize_y = *outh * vid.mode.height / vid_conheight.value;
 
        if (fsize_x < 0)
        {
@@ -1045,8 +1043,8 @@ int Font_IndexForSize(ft2_font_t *font, float _fsize, float *outw, float *outh)
        if (value <= r_font_size_snapping.value)
        {
                // do NOT keep the aspect for perfect rendering
-               if (outh) *outh = maps[match]->size * vid_conheight.value / vid.height;
-               if (outw) *outw = maps[match]->size * vid_conwidth.value / vid.width;
+               if (outh) *outh = maps[match]->size * vid_conheight.value / vid.mode.height;
+               if (outw) *outw = maps[match]->size * vid_conwidth.value / vid.mode.width;
        }
        return match;
 }