From: divverent Date: Fri, 25 Dec 2009 18:11:18 +0000 (+0000) Subject: stringwidth(): if 3rd arg is not given, always yield the size for 8x8 text, unsnapped... X-Git-Tag: xonotic-v0.1.0preview~954 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6caabd3bea878e7410606281165d8ea02e57868d;p=xonotic%2Fdarkplaces.git stringwidth(): if 3rd arg is not given, always yield the size for 8x8 text, unsnapped, divided by 8 git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9694 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/prvm_cmds.c b/prvm_cmds.c index 3d6cec40..5ed34b79 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -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);