@@ -628,21 +628,20 @@ struct DepotWindow : Window {
SetDParam(0, 100);
this->count_width = GetStringBoundingBox(STR_TINY_BLACK_COMA).width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
} else {
this->count_width = 0;
}
SetDParam(0, 999);
Dimension unumber = GetStringBoundingBox(STR_BLACK_COMMA);
Dimension unumber = { GetDigitWidth() * 4, FONT_HEIGHT_NORMAL };
const Sprite *spr = GetSprite(SPR_FLAG_VEH_STOPPED, ST_NORMAL);
this->flag_width = spr->width + WD_FRAMERECT_RIGHT;
this->flag_height = spr->height;
if (this->type == VEH_TRAIN || this->type == VEH_ROAD) {
min_height = max<uint>(unumber.height + WD_MATRIX_TOP, spr->height);
this->header_width = unumber.width + this->flag_width;
this->header_width = unumber.width + this->flag_width + WD_FRAMERECT_LEFT;
min_height = unumber.height + spr->height + WD_MATRIX_TOP + WD_PAR_VSEP_NORMAL + WD_MATRIX_BOTTOM;
this->header_width = max<uint>(unumber.width, this->flag_width) + WD_FRAMERECT_RIGHT;
int base_width = this->count_width + this->header_width;
@@ -1303,12 +1303,26 @@ byte GetCharacterWidth(FontSize size, WC
/* Use _stringwidth_table cache if possible */
if (key >= 32 && key < 256) return _stringwidth_table[size][key - 32];
return GetGlyphWidth(size, key);
/**
* Return the maximum width of single digit.
* @param size Font of the digit
* @return Width of the digit.
*/
byte GetDigitWidth(FontSize size)
{
byte width = 0;
for (char c = '0'; c <= '9'; c++) {
width = max(GetCharacterWidth(size, c), width);
return width;
void ScreenSizeChanged()
_dirty_bytes_per_line = (_screen.width + DIRTY_BLOCK_WIDTH - 1) / DIRTY_BLOCK_WIDTH;
_dirty_blocks = ReallocT<byte>(_dirty_blocks, _dirty_bytes_per_line * ((_screen.height + DIRTY_BLOCK_HEIGHT - 1) / DIRTY_BLOCK_HEIGHT));
@@ -157,12 +157,13 @@ void SortResolutions(int count);
bool ToggleFullScreen(bool fs);
/* gfx.cpp */
extern FontSize _cur_fontsize; ///< Currently selected font.
byte GetCharacterWidth(FontSize size, uint32 key);
byte GetDigitWidth(FontSize size = FS_NORMAL);
* Get height of a character for a given font size.
* @param size Font size to get height of
* @return Height of characters in the given font (pixels)
Status change: