diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 1a7460ce43..62a8e18c6d 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -2181,10 +2181,10 @@ DEF_CONSOLE_CMD(ConFont) IConsolePrint(CC_HELP, " Print out the fonts configuration."); IConsolePrint(CC_HELP, " The \"Currently active\" configuration is the one actually in effect (after interface scaling and replacing unavailable fonts)."); IConsolePrint(CC_HELP, " The \"Requested\" configuration is the one requested via console command or config file."); - IConsolePrint(CC_HELP, "Usage 'font [medium|small|large|mono] [] [] [aa|noaa]'."); + IConsolePrint(CC_HELP, "Usage 'font [medium|small|large|mono] [] []'."); IConsolePrint(CC_HELP, " Change the configuration for a font."); IConsolePrint(CC_HELP, " Omitting an argument will keep the current value."); - IConsolePrint(CC_HELP, " Set to \"\" for the default font. Note that and aa/noaa have no effect if the default font is in use, and fixed defaults are used instead."); + IConsolePrint(CC_HELP, " Set to \"\" for the default font. Note that has no effect if the default font is in use, and fixed defaults are used instead."); IConsolePrint(CC_HELP, " If the sprite font is enabled in Game Options, it is used instead of the default font."); IConsolePrint(CC_HELP, " The is automatically multiplied by the current interface scaling."); return true; @@ -2202,38 +2202,23 @@ DEF_CONSOLE_CMD(ConFont) FontCacheSubSetting *setting = GetFontCacheSubSetting(argfs); std::string font = setting->font; uint size = setting->size; - bool aa = setting->aa; - + uint v; uint8_t arg_index = 2; - /* We may encounter "aa" or "noaa" but it must be the last argument. */ - if (StrEqualsIgnoreCase(argv[arg_index], "aa") || StrEqualsIgnoreCase(argv[arg_index], "noaa")) { - aa = !StrStartsWithIgnoreCase(argv[arg_index++], "no"); - if (argc > arg_index) return false; - } else { - /* For we want a string. */ - uint v; - if (!GetArgumentInteger(&v, argv[arg_index])) { - font = argv[arg_index++]; - } + /* For we want a string. */ + + if (!GetArgumentInteger(&v, argv[arg_index])) { + font = argv[arg_index++]; } if (argc > arg_index) { /* For we want a number. */ - uint v; if (GetArgumentInteger(&v, argv[arg_index])) { size = v; arg_index++; } } - if (argc > arg_index) { - /* Last argument must be "aa" or "noaa". */ - if (!StrEqualsIgnoreCase(argv[arg_index], "aa") && !StrEqualsIgnoreCase(argv[arg_index], "noaa")) return false; - aa = !StrStartsWithIgnoreCase(argv[arg_index++], "no"); - if (argc > arg_index) return false; - } - - SetFont(argfs, font, size, aa); + SetFont(argfs, font, size); } for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) { @@ -2245,8 +2230,8 @@ DEF_CONSOLE_CMD(ConFont) fc = FontCache::Get(fs); } IConsolePrint(CC_DEFAULT, "{} font:", FontSizeToName(fs)); - IConsolePrint(CC_DEFAULT, "Currently active: \"{}\", size {}, {}", fc->GetFontName(), fc->GetFontSize(), GetFontAAState(fs) ? "aa" : "noaa"); - IConsolePrint(CC_DEFAULT, "Requested: \"{}\", size {}, {}", setting->font, setting->size, setting->aa ? "aa" : "noaa"); + IConsolePrint(CC_DEFAULT, "Currently active: \"{}\", size {}", fc->GetFontName(), fc->GetFontSize()); + IConsolePrint(CC_DEFAULT, "Requested: \"{}\", size {}", setting->font, setting->size); } return true; diff --git a/src/fontcache.cpp b/src/fontcache.cpp index 2a5772fc3b..1f01e9b327 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -91,15 +91,15 @@ int GetCharacterHeight(FontSize size) } /* Check if a glyph should be rendered with anti-aliasing. */ -bool GetFontAAState(FontSize size, bool check_blitter) +bool GetFontAAState() { /* AA is only supported for 32 bpp */ - if (check_blitter && BlitterFactory::GetCurrentBlitter()->GetScreenDepth() != 32) return false; + if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() != 32) return false; - return _fcsettings.global_aa || GetFontCacheSubSetting(size)->aa; + return _fcsettings.global_aa; } -void SetFont(FontSize fontsize, const std::string &font, uint size, bool aa) +void SetFont(FontSize fontsize, const std::string &font, uint size) { FontCacheSubSetting *setting = GetFontCacheSubSetting(fontsize); bool changed = false; @@ -114,11 +114,6 @@ void SetFont(FontSize fontsize, const std::string &font, uint size, bool aa) changed = true; } - if (setting->aa != aa) { - setting->aa = aa; - changed = true; - } - if (!changed) return; if (fontsize != FS_MONO) { @@ -233,19 +228,6 @@ void UninitFontCache() #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) bool SetFallbackFont(FontCacheSettings *, const std::string &, int, MissingGlyphSearcher *) { return false; } diff --git a/src/fontcache.h b/src/fontcache.h index 9ba6055504..fee0e26f3e 100644 --- a/src/fontcache.h +++ b/src/fontcache.h @@ -207,7 +207,6 @@ inline bool GetDrawGlyphShadow(FontSize size) struct FontCacheSubSetting { std::string font; ///< The name of the font, or path to the font. uint size; ///< The (requested) size of the font. - bool aa; ///< Whether to do anti aliasing or not. const void *os_handle = nullptr; ///< Optional native OS font info. Only valid during font search. }; @@ -242,9 +241,8 @@ inline FontCacheSubSetting *GetFontCacheSubSetting(FontSize fs) void InitFontCache(bool monospace); void UninitFontCache(); -bool HasAntialiasedFonts(); -bool GetFontAAState(FontSize size, bool check_blitter = true); -void SetFont(FontSize fontsize, const std::string &font, uint size, bool aa); +bool GetFontAAState(); +void SetFont(FontSize fontsize, const std::string &font, uint size); #endif /* FONTCACHE_H */ diff --git a/src/fontcache/truetypefontcache.cpp b/src/fontcache/truetypefontcache.cpp index 196add775c..9e16c363c1 100644 --- a/src/fontcache/truetypefontcache.cpp +++ b/src/fontcache/truetypefontcache.cpp @@ -91,7 +91,7 @@ void TrueTypeFontCache::SetGlyphPtr(GlyphID key, const GlyphEntry *glyph, bool d bool TrueTypeFontCache::GetDrawGlyphShadow() { - return this->fs == FS_NORMAL && GetFontAAState(FS_NORMAL); + return this->fs == FS_NORMAL && GetFontAAState(); } uint TrueTypeFontCache::GetGlyphWidth(GlyphID key) @@ -162,7 +162,7 @@ const Sprite *TrueTypeFontCache::GetGlyph(GlyphID key) } } - return this->InternalGetGlyph(key, GetFontAAState(this->fs)); + return this->InternalGetGlyph(key, GetFontAAState()); } const void *TrueTypeFontCache::GetFontTable(uint32_t tag, size_t &length) diff --git a/src/gfx_layout_icu.cpp b/src/gfx_layout_icu.cpp index e0008f2fa5..de9dae6c91 100644 --- a/src/gfx_layout_icu.cpp +++ b/src/gfx_layout_icu.cpp @@ -151,7 +151,7 @@ void ICURun::Shape(UChar *buff, size_t buff_length) { auto hbfont = hb_ft_font_create_referenced(*(static_cast(font->fc->GetOSHandle()))); /* Match the flags with how we render the glyphs. */ - hb_ft_font_set_load_flags(hbfont, GetFontAAState(this->font->fc->GetSize()) ? FT_LOAD_TARGET_NORMAL : FT_LOAD_TARGET_MONO); + hb_ft_font_set_load_flags(hbfont, GetFontAAState() ? FT_LOAD_TARGET_NORMAL : FT_LOAD_TARGET_MONO); /* ICU buffer is in UTF-16. */ auto hbbuf = hb_buffer_create(); diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp index 7971222ccf..62b69f2646 100644 --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -266,7 +266,7 @@ static bool SwitchNewGRFBlitter() 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; + if (GetFontAAState()) depth_wanted_by_grf = 32; /* Search the best blitter. */ static const struct { diff --git a/src/table/settings/misc_settings.ini b/src/table/settings/misc_settings.ini index 21fec3d5f3..e572d41773 100644 --- a/src/table/settings/misc_settings.ini +++ b/src/table/settings/misc_settings.ini @@ -237,30 +237,6 @@ def = 0 min = 0 max = 72 -[SDTG_BOOL] -ifdef = HAS_TRUETYPE_FONT -name = ""small_aa"" -var = _fcsettings.small.aa -def = false - -[SDTG_BOOL] -ifdef = HAS_TRUETYPE_FONT -name = ""medium_aa"" -var = _fcsettings.medium.aa -def = false - -[SDTG_BOOL] -ifdef = HAS_TRUETYPE_FONT -name = ""large_aa"" -var = _fcsettings.large.aa -def = false - -[SDTG_BOOL] -ifdef = HAS_TRUETYPE_FONT -name = ""mono_aa"" -var = _fcsettings.mono.aa -def = false - [SDTG_BOOL] ifdef = HAS_TRUETYPE_FONT name = ""global_aa""