]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
stringwidth(): if 3rd arg is not given, always yield the size for 8x8 text, unsnapped...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 25 Dec 2009 18:11:18 +0000 (18:11 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 25 Dec 2009 18:11:18 +0000 (18:11 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9694 d7cf8633-e32d-0410-b094-e92efae38249

prvm_cmds.c

index 3d6cec40bdfe641e2b960affc620e67f02c36c30..5ed34b794a1958a3ceb27eeba91e7121ab76169f 100644 (file)
@@ -3397,6 +3397,7 @@ void VM_stringwidth(void)
        size_t maxlen = 0;
        VM_SAFEPARMCOUNTRANGE(2,3,VM_drawstring);
 
+       getdrawfontscale(&sx, &sy);
        if(prog->argc == 3)
        {
                szv = PRVM_G_VECTOR(OFS_PARM2);
@@ -3404,11 +3405,18 @@ void VM_stringwidth(void)
        }
        else
        {
-               static float defsize[] = {0, 0};
+               // we want the width for 8x8 font size, divided by 8
+               static float defsize[] = {8, 8};
                szv = defsize;
-               mult = 1;
+               mult = 0.125;
+               // to make sure snapping is turned off, ALWAYS use a nontrivial scale in this case
+               if(sx >= 0.9 && sx <= 1.1)
+               {
+                       mult *= 2;
+                       sx /= 2;
+                       sy /= 2;
+               }
        }
-       getdrawfontscale(&sx, &sy);
 
        string = PRVM_G_STRING(OFS_PARM0);
        colors = (int)PRVM_G_FLOAT(OFS_PARM1);