return true;
}
-static float Font_VirtualToRealSize(float sz)
+float Font_VirtualToRealSize(float sz)
{
int vh, vw, si;
float sn;
return si;
}
-static float Font_SnapTo(float val, float snapwidth)
+float Font_SnapTo(float val, float snapwidth)
{
return floor(val / snapwidth + 0.5f) * snapwidth;
}
break;
}
count = 0;
- for (s = 0; s < MAX_FONT_SIZES; ++s)
+ for (s = 0; s < MAX_FONT_SIZES && dpfnt->req_sizes[s] >= 0; ++s)
{
if (Font_LoadSize(fb, Font_VirtualToRealSize(dpfnt->req_sizes[s]), true, false))
++count;
}
count = 0;
- for (s = 0; s < MAX_FONT_SIZES; ++s)
+ for (s = 0; s < MAX_FONT_SIZES && dpfnt->req_sizes[s] >= 0; ++s)
{
if (Font_LoadSize(ft2, Font_VirtualToRealSize(dpfnt->req_sizes[s]), false, false))
++count;
qboolean Font_LoadFont(const char *name, dp_font_t *dpfnt);
qboolean Font_GetKerningForSize(ft2_font_t *font, float w, float h, Uchar left, Uchar right, float *outx, float *outy);
qboolean Font_GetKerningForMap(ft2_font_t *font, int map_index, float w, float h, Uchar left, Uchar right, float *outx, float *outy);
-
+float Font_VirtualToRealSize(float sz);
+float Font_SnapTo(float val, float snapwidth);
// since this is used on a font_map_t, let's name it FontMap_*
ft2_font_map_t *FontMap_FindForChar(ft2_font_map_t *start, Uchar ch);
#endif // DP_FREETYPE2_H__
fnt->width_of[ch] = atof(com_token) + extraspacing;
if (fnt->ft2)
{
- for (i = 0; i < MAX_FONT_SIZES && fnt->req_sizes[i] >= 0; ++i)
- Font_MapForIndex(fnt->ft2, i)->width_of[ch] = snap_to_pixel_x(fnt->width_of[ch] * fnt->req_sizes[i], 0.4);
+ for (i = 0; i < MAX_FONT_SIZES; ++i)
+ {
+ //Font_MapForIndex(fnt->ft2, i)->width_of[ch] = snap_to_pixel_x(fnt->width_of[ch] * fnt->req_sizes[i], 0.4);
+ ft2_font_map_t *map = Font_MapForIndex(fnt->ft2, i);
+ if (!map)
+ break;
+ map->width_of[ch] = Font_SnapTo(fnt->width_of[ch], 1/map->size);
+ }
}
ch++;
break;
for(i = 1; i < MAX_FONT_SIZES; ++i)
f->req_sizes[i] = -1;
- // for some reason this argc is 3 even when using 2 arguments here, maybe nexuiz screws up
if(Cmd_Argc() >= 3)
{
for(i = 0; i < Cmd_Argc()-3; ++i)
if (fontmap)
{
- width_of_factor = 1;
+ width_of_factor = dw;
width_of = fontmap->width_of;
}
else
if (fontmap)
{
- width_of_factor = 1;
+ width_of_factor = dw;
width_of = fontmap->width_of;
}
else