summaryrefslogtreecommitdiff
path: root/src/fontcache.cpp
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-02-23 20:54:50 +0100
committerMichael Lutz <michi@icosahedron.de>2021-02-23 22:15:03 +0100
commit46e13313e4eada30a8aef857731e0a12664e02d1 (patch)
tree8e1c11319709566a6a7d096b4bd4564bacb4d170 /src/fontcache.cpp
parentc93c9c099e5b29ad3fb9e33cef7783e92fa129a6 (diff)
downloadopenttd-46e13313e4eada30a8aef857731e0a12664e02d1.tar.xz
Fix #8731: Always use a 32bpp blitter if font anti-aliasing is enabled.
Diffstat (limited to 'src/fontcache.cpp')
-rw-r--r--src/fontcache.cpp17
1 files changed, 15 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