mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Don't pre-fill font metrics when loading fonts. (#14436)
Each font cache implementation sets its own metrics based on the loaded font, so there is no need to pre-fill with (unscaled, invalid) default metrics.pull/14437/head
parent
3c4fb21a5e
commit
bf6d0c4934
|
@ -22,9 +22,10 @@
|
|||
|
||||
#include "safeguards.h"
|
||||
|
||||
/** Default heights for the different sizes of fonts. */
|
||||
static const int _default_font_height[FS_END] = {10, 6, 18, 10};
|
||||
static const int _default_font_ascender[FS_END] = { 8, 5, 15, 8};
|
||||
/** Default unscaled heights for the different sizes of fonts. */
|
||||
/* static */ const int FontCache::DEFAULT_FONT_HEIGHT[FS_END] = {10, 6, 18, 10};
|
||||
/** Default unscaled ascenders for the different sizes of fonts. */
|
||||
/* static */ const int FontCache::DEFAULT_FONT_ASCENDER[FS_END] = {8, 5, 15, 8};
|
||||
|
||||
FontCacheSettings _fcsettings;
|
||||
|
||||
|
@ -32,8 +33,7 @@ FontCacheSettings _fcsettings;
|
|||
* Create a new font cache.
|
||||
* @param fs The size of the font.
|
||||
*/
|
||||
FontCache::FontCache(FontSize fs) : parent(FontCache::Get(fs)), fs(fs), height(_default_font_height[fs]),
|
||||
ascender(_default_font_ascender[fs]), descender(_default_font_ascender[fs] - _default_font_height[fs])
|
||||
FontCache::FontCache(FontSize fs) : parent(FontCache::Get(fs)), fs(fs)
|
||||
{
|
||||
assert(this->parent == nullptr || this->fs == this->parent->fs);
|
||||
FontCache::caches[this->fs] = this;
|
||||
|
@ -50,7 +50,7 @@ FontCache::~FontCache()
|
|||
|
||||
int FontCache::GetDefaultFontHeight(FontSize fs)
|
||||
{
|
||||
return _default_font_height[fs];
|
||||
return FontCache::DEFAULT_FONT_HEIGHT[fs];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -23,9 +23,9 @@ protected:
|
|||
static FontCache *caches[FS_END]; ///< All the font caches.
|
||||
FontCache *parent; ///< The parent of this font cache.
|
||||
const FontSize fs; ///< The size of the font.
|
||||
int height; ///< The height of the font.
|
||||
int ascender; ///< The ascender value of the font.
|
||||
int descender; ///< The descender value of the font.
|
||||
int height = 0; ///< The height of the font.
|
||||
int ascender = 0; ///< The ascender value of the font.
|
||||
int descender = 0; ///< The descender value of the font.
|
||||
|
||||
public:
|
||||
FontCache(FontSize fs);
|
||||
|
@ -33,6 +33,11 @@ public:
|
|||
|
||||
static void InitializeFontCaches();
|
||||
|
||||
/** Default unscaled font heights. */
|
||||
static const int DEFAULT_FONT_HEIGHT[FS_END];
|
||||
/** Default unscaled font ascenders. */
|
||||
static const int DEFAULT_FONT_ASCENDER[FS_END];
|
||||
|
||||
static int GetDefaultFontHeight(FontSize fs);
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue