Changeset - r28255:2fb69767d82f
[Not reviewed]
master
0 2 0
Peter Nelson - 7 months ago 2023-11-29 12:35:00
peter1138@openttd.org
Fix: Don't implicitly ReInit all windows after updating the character width cache.

This caused duplicate ReInit when changing interface scale.
2 files changed with 1 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/gfx.cpp
Show inline comments
 
@@ -1397,26 +1397,24 @@ TextColour GetContrastColour(uint8_t bac
 
 * Initialize _stringwidth_table cache
 
 * @param monospace Whether to load the monospace cache or the normal fonts.
 
 */
 
void LoadStringWidthTable(bool monospace)
 
{
 
	ClearFontCache();
 

	
 
	for (FontSize fs = monospace ? FS_MONO : FS_BEGIN; fs < (monospace ? FS_END : FS_MONO); fs++) {
 
		for (uint i = 0; i != 224; i++) {
 
			_stringwidth_table[fs][i] = GetGlyphWidth(fs, i + 32);
 
		}
 
	}
 

	
 
	ReInitAllWindows(false);
 
}
 

	
 
/**
 
 * Return width of character glyph.
 
 * @param size  Font of the character
 
 * @param key   Character code glyph
 
 * @return Width of the character glyph
 
 */
 
byte GetCharacterWidth(FontSize size, char32_t key)
 
{
 
	/* Use _stringwidth_table cache if possible */
 
	if (key >= 32 && key < 256) return _stringwidth_table[size][key - 32];
src/settings_table.cpp
Show inline comments
 
@@ -261,24 +261,25 @@ static void TownFoundingChanged(int32_t)
 
	}
 
}
 

	
 
static void ZoomMinMaxChanged(int32_t)
 
{
 
	ConstrainAllViewportsZoom();
 
	GfxClearSpriteCache();
 
	if (_settings_client.gui.zoom_min > _gui_zoom) {
 
		/* Restrict GUI zoom if it is no longer available. */
 
		_gui_zoom = _settings_client.gui.zoom_min;
 
		UpdateCursorSize();
 
		LoadStringWidthTable();
 
		ReInitAllWindows(true);
 
	}
 
}
 

	
 
static void SpriteZoomMinChanged(int32_t)
 
{
 
	GfxClearSpriteCache();
 
	/* Force all sprites to redraw at the new chosen zoom level */
 
	MarkWholeScreenDirty();
 
}
 

	
 
/**
 
 * Update any possible saveload window and delete any newgrf dialogue as
0 comments (0 inline, 0 general)