]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
stringwidth(): add a third font size argument (optional) to help with later porting...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 1 Jul 2009 06:39:45 +0000 (06:39 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 1 Jul 2009 06:39:45 +0000 (06:39 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9037 d7cf8633-e32d-0410-b094-e92efae38249

prvm_cmds.c

index 267cee53a39360e6f42c2d7b883aea978862767f..96a84546eaff7f49df41eda03cb93caefd63bc0b 100644 (file)
@@ -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
 }
 /*
 =========