MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SetFont

Function SetFont

src/fontcache.cpp:115–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113}
114
115void SetFont(FontSize fontsize, const std::string &font, uint size)
116{
117 FontCacheSubSetting *setting = GetFontCacheSubSetting(fontsize);
118 bool changed = false;
119
120 if (setting->font != font) {
121 setting->font = font;
122 changed = true;
123 }
124
125 if (setting->size != size) {
126 setting->size = size;
127 changed = true;
128 }
129
130 if (!changed) return;
131
132 if (fontsize != FS_MONO) {
133 /* Try to reload only the modified font. */
134 FontCacheSettings backup = _fcsettings;
135 for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
136 if (fs == fontsize) continue;
137 FontCache *fc = FontCache::Get(fs);
138 GetFontCacheSubSetting(fs)->font = fc->HasParent() ? fc->GetFontName() : "";
139 }
140 CheckForMissingGlyphs();
141 _fcsettings = std::move(backup);
142 } else {
143 FontCache::LoadFontCaches(fontsize);
144 }
145
146 LoadStringWidthTable(fontsize);
147 UpdateAllVirtCoords();
148 ReInitAllWindows(true);
149
150 if (_save_config) SaveToConfig();
151}
152
153/**
154 * Test if a font setting uses the default font.

Callers 1

ConFontFunction · 0.85

Calls 8

GetFontCacheSubSettingFunction · 0.85
CheckForMissingGlyphsFunction · 0.85
LoadStringWidthTableFunction · 0.85
UpdateAllVirtCoordsFunction · 0.85
ReInitAllWindowsFunction · 0.85
SaveToConfigFunction · 0.85
HasParentMethod · 0.80
GetFontNameMethod · 0.45

Tested by

no test coverage detected