From d3e7158071087b92831a876378f54d2b9063d4ff Mon Sep 17 00:00:00 2001 From: divverent Date: Wed, 1 Jul 2009 06:39:45 +0000 Subject: [PATCH] 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 --- prvm_cmds.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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 } /* ========= -- 2.39.2