]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/menu/draw.qc
Merge branch 'master' into Mario/vaporizer_damage
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / draw.qc
index 9c0d032432f384a60299fddc697c5b2df918ee06..19d18223aa852c8362126dc66f14004eb2baffa9 100644 (file)
@@ -276,8 +276,10 @@ void draw_BorderPicture(vector theOrigin, string pic, vector theSize, vector the
 }
 void draw_Text(vector theOrigin, string theText, vector theSize, vector theColor, float theAlpha, float ICanHasKallerz)
 {
-       if(theSize_x <= 0 || theSize_y <= 0)
-               error("Drawing zero size text?\n");
+       if(theSize_x <= 0 || theSize_y <= 0) {
+               dprint("Drawing zero size text?\n");
+               return;
+       }
 
        //float wi;
        //wi = draw_TextWidth(theText, ICanHasKallerz, theSize);
@@ -306,6 +308,16 @@ float draw_TextWidth(string theText, float ICanHasKallerz, vector SizeThxBye)
        return v_x;
 }
 
+float draw_CondensedFontFactor(string theText, float ICanHasKallerz, vector SizeThxBye, float maxWidth)
+{
+       float w = draw_TextWidth(theText, ICanHasKallerz, SizeThxBye);
+       if (w > maxWidth) {
+               //dprintf("NOTE: label text %s too wide for label, condensed by factor %f\n", theText, maxWidth / w);
+               return maxWidth / w;
+       }
+       return 1.0;
+}
+
 float draw_clipSet;
 void draw_SetClip()
 {