static void LoadFont(qboolean override, const char *name, dp_font_t *fnt)
{
int i;
- float maxwidth;
+ float maxwidth, scale;
char widthfile[MAX_QPATH];
char *widthbuf;
fs_offset_t widthbufsize;
// unspecified width == 1 (base width)
for(i = 1; i < 256; ++i)
fnt->width_of[i] = 1;
+ scale = 1;
// FIXME load "name.width", if it fails, fill all with 1
if((widthbuf = (char *) FS_LoadFile(widthfile, tempmempool, true, &widthbufsize)))
return;
extraspacing = atof(com_token);
}
+ else if(!strcmp(com_token, "scale"))
+ {
+ if(!COM_ParseToken_Simple(&p, false, false))
+ return;
+ scale = atof(com_token);
+ }
else
fnt->width_of[ch++] = atof(com_token) + extraspacing;
}
maxwidth = fnt->width_of[1];
for(i = 2; i < 256; ++i)
maxwidth = max(maxwidth, fnt->width_of[i]);
- fnt->width_of[0] = maxwidth;
+ fnt->maxwidth = maxwidth;
+
+ // fix up maxwidth for overlap
+ fnt->maxwidth *= scale;
+ fnt->scale = scale;
if(fnt == FONT_CONSOLE)
con_linewidth = -1; // rewrap console in next frame
else
colorindex = *outcolor;
+ maxwidth /= fnt->scale;
+
for (i = 0;i < *maxlen && text[i];i++)
{
if (text[i] == ' ')
if (outcolor)
*outcolor = colorindex;
- return x;
+ return x * fnt->scale;
}
float DrawQ_String_Font(float startx, float starty, const char *text, size_t maxlen, float w, float h, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor, qboolean ignorecolorcodes, const dp_font_t *fnt)
tw = R_TextureWidth(fnt->tex);
th = R_TextureHeight(fnt->tex);
+ starty -= (fnt->scale - 1) * h * 0.5; // center
+ w *= fnt->scale;
+ h *= fnt->scale;
+
if (maxlen < 1)
maxlen = 1<<30;
//
//
c = palette_rgb_pantsscoreboard[(s->colors & 0xf0) >> 4];
- DrawQ_Fill(x + 14*8*FONT_SBAR->width_of[0], y+1, 40*FONT_SBAR->width_of[0], 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), sbar_alpha_fg.value, 0);
+ DrawQ_Fill(x + 14*8*FONT_SBAR->maxwidth, y+1, 40*FONT_SBAR->maxwidth, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), sbar_alpha_fg.value, 0);
c = palette_rgb_shirtscoreboard[s->colors & 0xf];
- DrawQ_Fill(x + 14*8*FONT_SBAR->width_of[0], y+4, 40*FONT_SBAR->width_of[0], 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), sbar_alpha_fg.value, 0);
+ DrawQ_Fill(x + 14*8*FONT_SBAR->maxwidth, y+4, 40*FONT_SBAR->maxwidth, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), sbar_alpha_fg.value, 0);
// print the text
//DrawQ_String(x, y, va("%c%4i %s", myself ? 13 : ' ', (int) s->frags, s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0, NULL, true);
if (s->qw_ping || s->qw_packetloss)
{
// draw colors behind score
c = palette_rgb_pantsscoreboard[(s->colors & 0xf0) >> 4];
- DrawQ_Fill(x + 9*8*FONT_SBAR->width_of[0], y+1, 40*FONT_SBAR->width_of[0], 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), sbar_alpha_fg.value, 0);
+ DrawQ_Fill(x + 9*8*FONT_SBAR->maxwidth, y+1, 40*FONT_SBAR->maxwidth, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), sbar_alpha_fg.value, 0);
c = palette_rgb_shirtscoreboard[s->colors & 0xf];
- DrawQ_Fill(x + 9*8*FONT_SBAR->width_of[0], y+4, 40*FONT_SBAR->width_of[0], 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), sbar_alpha_fg.value, 0);
+ DrawQ_Fill(x + 9*8*FONT_SBAR->maxwidth, y+4, 40*FONT_SBAR->maxwidth, 3, c[0] * (1.0f / 255.0f), c[1] * (1.0f / 255.0f), c[2] * (1.0f / 255.0f), sbar_alpha_fg.value, 0);
// print the text
//DrawQ_String(x, y, va("%c%4i %s", myself ? 13 : ' ', (int) s->frags, s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0, NULL, true);
if (s->qw_ping || s->qw_packetloss)
ymax = 40 + 8 + (Sbar_IsTeammatch() ? (teamlines * 8 + 5): 0) + scoreboardlines * 8 - 1;
if (cls.protocol == PROTOCOL_QUAKEWORLD)
- xmin = (vid_conwidth.integer - (26 + 15) * 8 * FONT_SBAR->width_of[0]) / 2; // 26 characters until name, then we assume 15 character names (they can be longer but usually aren't)
+ xmin = (vid_conwidth.integer - (26 + 15) * 8 * FONT_SBAR->maxwidth) / 2; // 26 characters until name, then we assume 15 character names (they can be longer but usually aren't)
else
- xmin = (vid_conwidth.integer - (16 + 25) * 8 * FONT_SBAR->width_of[0]) / 2; // 16 characters until name, then we assume 25 character names (they can be longer but usually aren't)
+ xmin = (vid_conwidth.integer - (16 + 25) * 8 * FONT_SBAR->maxwidth) / 2; // 16 characters until name, then we assume 25 character names (they can be longer but usually aren't)
xmax = vid_conwidth.integer - xmin;
if(gamemode == GAME_NEXUIZ)