From: divverent Date: Wed, 1 Jul 2009 06:39:45 +0000 (+0000) Subject: stringwidth(): add a third font size argument (optional) to help with later porting... X-Git-Tag: xonotic-v0.1.0preview~1589 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d3e7158071087b92831a876378f54d2b9063d4ff;p=xonotic%2Fdarkplaces.git stringwidth(): add a third font size argument (optional) to help with later porting to freetype git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9037 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/prvm_cmds.c b/prvm_cmds.c index 267cee53..96a84546 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -3120,19 +3120,30 @@ void VM_drawcolorcodedstring(void) ========= VM_stringwidth -float stringwidth(string text, float allowColorCodes) +float stringwidth(string text, float allowColorCodes, float size) ========= */ void VM_stringwidth(void) { const char *string; + float sz, mult; // sz is intended font size so we can later add freetype support, mult is font size multiplier in pixels per character cell int colors; - VM_SAFEPARMCOUNT(2,VM_drawstring); + VM_SAFEPARMCOUNTRANGE(2,3,VM_drawstring); + + if(prog->argc == 3) + { + mult = sz = PRVM_G_FLOAT(OFS_PARM2); + } + else + { + sz = 8; + mult = 1; + } string = PRVM_G_STRING(OFS_PARM0); colors = (int)PRVM_G_FLOAT(OFS_PARM1); - PRVM_G_FLOAT(OFS_RETURN) = DrawQ_TextWidth_Font(string, 0, !colors, getdrawfont()); // 1x1 characters, don't actually draw + PRVM_G_FLOAT(OFS_RETURN) = DrawQ_TextWidth_Font(string, 0, !colors, getdrawfont()) * mult; // 1x1 characters, don't actually draw } /* =========