| 113 | } |
| 114 | |
| 115 | void 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. |
no test coverage detected