diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-02-23 20:54:50 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-02-23 22:15:03 +0100 |
commit | 46e13313e4eada30a8aef857731e0a12664e02d1 (patch) | |
tree | 8e1c11319709566a6a7d096b4bd4564bacb4d170 /src | |
parent | c93c9c099e5b29ad3fb9e33cef7783e92fa129a6 (diff) | |
download | openttd-46e13313e4eada30a8aef857731e0a12664e02d1.tar.xz |
Fix #8731: Always use a 32bpp blitter if font anti-aliasing is enabled.
Diffstat (limited to 'src')
-rw-r--r-- | src/fontcache.cpp | 17 | ||||
-rw-r--r-- | src/fontcache.h | 1 | ||||
-rw-r--r-- | src/gfxinit.cpp | 2 | ||||
-rw-r--r-- | src/settings_gui.cpp | 1 |
4 files changed, 19 insertions, 2 deletions
diff --git a/src/fontcache.cpp b/src/fontcache.cpp index 0ae597fa9..d450deaca 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -279,10 +279,10 @@ void TrueTypeFontCache::SetGlyphPtr(GlyphID key, const GlyphEntry *glyph, bool d /* 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 diff --git a/src/fontcache.h b/src/fontcache.h index 4b26af871..73675cf44 100644 --- a/src/fontcache.h +++ b/src/fontcache.h @@ -233,5 +233,6 @@ extern FreeTypeSettings _freetype; void InitFreeType(bool monospace); void UninitFreeType(); +bool HasAntialiasedFonts(); #endif /* FONTCACHE_H */ diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp index fe37c3eb5..7884f89b5 100644 --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -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 { diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index d2a22dff4..bec549890 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -433,6 +433,7 @@ struct GameOptionsWindow : Window { CheckForMissingGlyphs(); ClearAllCachedNames(); UpdateAllVirtCoords(); + CheckBlitter(); ReInitAllWindows(); break; |