File diff r26674:deb4e19e03ac → r26675:fc2319aeaced
src/fontcache.cpp
Show inline comments
 
@@ -13,6 +13,11 @@
 
#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"
 

	
 
@@ -73,6 +78,49 @@ bool GetFontAAState(FontSize size, bool 
 
	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.