|
@@ -10,12 +10,17 @@
|
|
|
#include "stdafx.h"
|
|
|
#include "fontcache.h"
|
|
|
#include "fontdetection.h"
|
|
|
#include "blitter/factory.hpp"
|
|
|
#include "gfx_layout.h"
|
|
|
#include "fontcache/spritefontcache.h"
|
|
|
#include "openttd.h"
|
|
|
#include "settings_func.h"
|
|
|
#include "strings_func.h"
|
|
|
#include "viewport_func.h"
|
|
|
#include "window_func.h"
|
|
|
|
|
|
#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};
|
|
@@ -70,12 +75,55 @@ bool GetFontAAState(FontSize size, bool
|
|
|
/* AA is only supported for 32 bpp */
|
|
|
if (check_blitter && BlitterFactory::GetCurrentBlitter()->GetScreenDepth() != 32) return false;
|
|
|
|
|
|
return GetFontCacheSubSetting(size)->aa;
|
|
|
}
|
|
|
|
|
|
void SetFont(FontSize fontsize, const std::string& font, uint size, bool aa)
|
|
|
{
|
|
|
FontCacheSubSetting *setting = GetFontCacheSubSetting(fontsize);
|
|
|
bool changed = false;
|
|
|
|
|
|
if (setting->font != font) {
|
|
|
setting->font = font;
|
|
|
changed = true;
|
|
|
}
|
|
|
|
|
|
if (setting->size != size) {
|
|
|
setting->size = size;
|
|
|
changed = true;
|
|
|
}
|
|
|
|
|
|
if (setting->aa != aa) {
|
|
|
setting->aa = aa;
|
|
|
changed = true;
|
|
|
}
|
|
|
|
|
|
if (!changed) return;
|
|
|
|
|
|
if (fontsize != FS_MONO) {
|
|
|
/* Try to reload only the modified font. */
|
|
|
FontCacheSettings backup = _fcsettings;
|
|
|
for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
|
|
|
if (fs == fontsize) continue;
|
|
|
FontCache *fc = FontCache::Get(fs);
|
|
|
GetFontCacheSubSetting(fs)->font = fc->HasParent() ? fc->GetFontName() : "";
|
|
|
}
|
|
|
CheckForMissingGlyphs();
|
|
|
_fcsettings = backup;
|
|
|
} else {
|
|
|
InitFontCache(true);
|
|
|
}
|
|
|
|
|
|
LoadStringWidthTable();
|
|
|
UpdateAllVirtCoords();
|
|
|
ReInitAllWindows(true);
|
|
|
|
|
|
if (_save_config) SaveToConfig();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* (Re)initialize the font cache related things, i.e. load the non-sprite fonts.
|
|
|
* @param monospace Whether to initialise the monospace or regular fonts.
|
|
|
*/
|
|
|
void InitFontCache(bool monospace)
|
|
|
{
|