Changeset - r24931:be251d09ce0e
[Not reviewed]
master
0 4 0
Michael Lutz - 3 years ago 2021-02-23 19:54:50
michi@icosahedron.de
Fix #8731: Always use a 32bpp blitter if font anti-aliasing is enabled.
4 files changed with 19 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/fontcache.cpp
Show inline comments
 
@@ -279,10 +279,10 @@ void TrueTypeFontCache::SetGlyphPtr(Glyp
 

	
 

	
 
/* Check if a glyph should be rendered with anti-aliasing. */
 
static bool GetFontAAState(FontSize size)
 
static bool GetFontAAState(FontSize size, bool check_blitter = true)
 
{
 
	/* AA is only supported for 32 bpp */
 
	if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() != 32) return false;
 
	if (check_blitter && BlitterFactory::GetCurrentBlitter()->GetScreenDepth() != 32) return false;
 

	
 
	switch (size) {
 
		default: NOT_REACHED();
 
@@ -716,6 +716,19 @@ void UninitFreeType()
 
#endif /* WITH_FREETYPE */
 
}
 

	
 
/**
 
 * Should any of the active fonts be anti-aliased?
 
 * @return True if any of the loaded fonts want anti-aliased drawing.
 
 */
 
bool HasAntialiasedFonts()
 
{
 
	for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
 
		if (!FontCache::Get(fs)->IsBuiltInFont() && GetFontAAState(fs, false)) return true;
 
	}
 

	
 
	return false;
 
}
 

	
 
#if !defined(_WIN32) && !defined(__APPLE__) && !defined(WITH_FONTCONFIG) && !defined(WITH_COCOA)
 

	
 
#ifdef WITH_FREETYPE
src/fontcache.h
Show inline comments
 
@@ -233,5 +233,6 @@ extern FreeTypeSettings _freetype;
 

	
 
void InitFreeType(bool monospace);
 
void UninitFreeType();
 
bool HasAntialiasedFonts();
 

	
 
#endif /* FONTCACHE_H */
src/gfxinit.cpp
Show inline comments
 
@@ -268,6 +268,8 @@ static bool SwitchNewGRFBlitter()
 
		if (c->status == GCS_DISABLED || c->status == GCS_NOT_FOUND || HasBit(c->flags, GCF_INIT_ONLY)) continue;
 
		if (c->palette & GRFP_BLT_32BPP) depth_wanted_by_grf = 32;
 
	}
 
	/* We need a 32bpp blitter for font anti-alias. */
 
	if (HasAntialiasedFonts()) depth_wanted_by_grf = 32;
 

	
 
	/* Search the best blitter. */
 
	static const struct {
src/settings_gui.cpp
Show inline comments
 
@@ -433,6 +433,7 @@ struct GameOptionsWindow : Window {
 
				CheckForMissingGlyphs();
 
				ClearAllCachedNames();
 
				UpdateAllVirtCoords();
 
				CheckBlitter();
 
				ReInitAllWindows();
 
				break;
 

	
0 comments (0 inline, 0 general)