From f6ad8e1c9cbbfb14035ff0716764363a256c677a Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 15 Sep 2022 18:21:27 +0100 Subject: [PATCH] Change: Rename some freetype things to fontcache. The font cache supports more than just FreeType as a font provider, but still used freetype in some naming. This now uses more suitable terms. --- src/bootstrap_gui.cpp | 6 ++--- src/debug.cpp | 4 +-- src/debug.h | 2 +- src/fontcache.cpp | 40 ++++++++++++++-------------- src/fontcache.h | 22 +++++++-------- src/fontdetection.h | 2 +- src/openttd.cpp | 6 ++--- src/os/macosx/font_osx.cpp | 18 ++++++------- src/os/unix/font_unix.cpp | 6 ++--- src/os/windows/font_win32.cpp | 26 +++++++++--------- src/strings.cpp | 20 +++++++------- src/strings_func.h | 2 +- src/table/settings/misc_settings.ini | 24 ++++++++--------- src/table/unicode.h | 2 +- src/textfile_gui.cpp | 2 +- src/textfile_gui.h | 2 +- 16 files changed, 92 insertions(+), 92 deletions(-) diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index d8e4aedec9..ddfda8f50b 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -286,16 +286,16 @@ bool HandleBootstrap() /* No user interface, bail out with an error. */ if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 0) goto failure; - /* If there is no network or no freetype, then there is nothing we can do. Go straight to failure. */ + /* If there is no network or no non-sprite font, then there is nothing we can do. Go straight to failure. */ #if (defined(_WIN32) && defined(WITH_UNISCRIBE)) || (defined(WITH_FREETYPE) && (defined(WITH_FONTCONFIG) || defined(__APPLE__))) || defined(WITH_COCOA) if (!_network_available) goto failure; /* First tell the game we're bootstrapping. */ _game_mode = GM_BOOTSTRAP; - /* Initialise the freetype font code. */ + /* Initialise the font cache. */ InitializeUnicodeGlyphMap(); - /* Next "force" finding a suitable freetype font as the local font is missing. */ + /* Next "force" finding a suitable non-sprite font as the local font is missing. */ CheckForMissingGlyphs(false); /* Initialise the palette. The biggest step is 'faking' some recolour sprites. diff --git a/src/debug.cpp b/src/debug.cpp index e13e58ec3f..7dc90b2bb7 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -46,7 +46,7 @@ int _debug_sprite_level; int _debug_oldloader_level; int _debug_npf_level; int _debug_yapf_level; -int _debug_freetype_level; +int _debug_fontcache_level; int _debug_script_level; int _debug_sl_level; int _debug_gamelog_level; @@ -72,7 +72,7 @@ struct DebugLevel { DEBUG_LEVEL(oldloader), DEBUG_LEVEL(npf), DEBUG_LEVEL(yapf), - DEBUG_LEVEL(freetype), + DEBUG_LEVEL(fontcache), DEBUG_LEVEL(script), DEBUG_LEVEL(sl), DEBUG_LEVEL(gamelog), diff --git a/src/debug.h b/src/debug.h index 932d3077b2..e7db3ee0e3 100644 --- a/src/debug.h +++ b/src/debug.h @@ -46,7 +46,7 @@ extern int _debug_sprite_level; extern int _debug_oldloader_level; extern int _debug_npf_level; extern int _debug_yapf_level; -extern int _debug_freetype_level; +extern int _debug_fontcache_level; extern int _debug_script_level; extern int _debug_sl_level; extern int _debug_gamelog_level; diff --git a/src/fontcache.cpp b/src/fontcache.cpp index deb651e37c..e082c59c01 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -32,7 +32,7 @@ static const int ASCII_LETTERSTART = 32; ///< First printable ASCII letter. static const int _default_font_height[FS_END] = {10, 6, 18, 10}; static const int _default_font_ascender[FS_END] = { 8, 5, 15, 8}; -FreeTypeSettings _freetype; +FontCacheSettings _fcsettings; /** * Create a new font cache. @@ -72,7 +72,7 @@ int GetCharacterHeight(FontSize size) } -/** Font cache for fonts that are based on a freetype font. */ +/** Font cache for fonts that are based on a sprite font. */ class SpriteFontCache : public FontCache { private: SpriteID **glyph_to_spriteid_map; ///< Mapping of glyphs to sprite IDs. @@ -259,16 +259,16 @@ TrueTypeFontCache::GlyphEntry *TrueTypeFontCache::GetGlyphPtr(GlyphID key) void TrueTypeFontCache::SetGlyphPtr(GlyphID key, const GlyphEntry *glyph, bool duplicate) { if (this->glyph_to_sprite == nullptr) { - Debug(freetype, 3, "Allocating root glyph cache for size {}", this->fs); + Debug(fontcache, 3, "Allocating root glyph cache for size {}", this->fs); this->glyph_to_sprite = CallocT(256); } if (this->glyph_to_sprite[GB(key, 8, 8)] == nullptr) { - Debug(freetype, 3, "Allocating glyph cache for range 0x{:02X}00, size {}", GB(key, 8, 8), this->fs); + Debug(fontcache, 3, "Allocating glyph cache for range 0x{:02X}00, size {}", GB(key, 8, 8), this->fs); this->glyph_to_sprite[GB(key, 8, 8)] = CallocT(256); } - Debug(freetype, 4, "Set glyph for unicode character 0x{:04X}, size {}", key, this->fs); + Debug(fontcache, 4, "Set glyph for unicode character 0x{:04X}, size {}", key, this->fs); this->glyph_to_sprite[GB(key, 8, 8)][GB(key, 0, 8)].sprite = glyph->sprite; this->glyph_to_sprite[GB(key, 8, 8)][GB(key, 0, 8)].width = glyph->width; this->glyph_to_sprite[GB(key, 8, 8)][GB(key, 0, 8)].duplicate = duplicate; @@ -283,10 +283,10 @@ static bool GetFontAAState(FontSize size, bool check_blitter = true) switch (size) { default: NOT_REACHED(); - case FS_NORMAL: return _freetype.medium.aa; - case FS_SMALL: return _freetype.small.aa; - case FS_LARGE: return _freetype.large.aa; - case FS_MONO: return _freetype.mono.aa; + case FS_NORMAL: return _fcsettings.medium.aa; + case FS_SMALL: return _fcsettings.small.aa; + case FS_LARGE: return _fcsettings.large.aa; + case FS_MONO: return _fcsettings.mono.aa; } } @@ -468,7 +468,7 @@ void FreeTypeFontCache::SetFontSize(FontSize fs, FT_Face face, int pixels) this->height = this->ascender - this->descender; } else { /* Both FT_Set_Pixel_Sizes and FT_Select_Size failed. */ - Debug(freetype, 0, "Font size selection failed. Using FontCache defaults."); + Debug(fontcache, 0, "Font size selection failed. Using FontCache defaults."); } } @@ -484,10 +484,10 @@ static void LoadFreeTypeFont(FontSize fs) FreeTypeSubSetting *settings = nullptr; switch (fs) { default: NOT_REACHED(); - case FS_SMALL: settings = &_freetype.small; break; - case FS_NORMAL: settings = &_freetype.medium; break; - case FS_LARGE: settings = &_freetype.large; break; - case FS_MONO: settings = &_freetype.mono; break; + case FS_SMALL: settings = &_fcsettings.small; break; + case FS_NORMAL: settings = &_fcsettings.medium; break; + case FS_LARGE: settings = &_fcsettings.large; break; + case FS_MONO: settings = &_fcsettings.mono; break; } if (settings->font.empty()) return; @@ -498,7 +498,7 @@ static void LoadFreeTypeFont(FontSize fs) return; } - Debug(freetype, 2, "Initialized"); + Debug(fontcache, 2, "Initialized"); } const char *font_name = settings->font.c_str(); @@ -527,7 +527,7 @@ static void LoadFreeTypeFont(FontSize fs) if (error != FT_Err_Ok) error = GetFontByFaceName(font_name, &face); if (error == FT_Err_Ok) { - Debug(freetype, 2, "Requested '{}', using '{} {}'", font_name, face->family_name, face->style_name); + Debug(fontcache, 2, "Requested '{}', using '{} {}'", font_name, face->family_name, face->style_name); /* Attempt to select the unicode character map */ error = FT_Select_Charmap(face, ft_encoding_unicode); @@ -675,10 +675,10 @@ const void *FreeTypeFontCache::InternalGetFontTable(uint32 tag, size_t &length) /** - * (Re)initialize the freetype related things, i.e. load the non-sprite fonts. + * (Re)initialize the font cache related things, i.e. load the non-sprite fonts. * @param monospace Whether to initialise the monospace or regular fonts. */ -void InitFreeType(bool monospace) +void InitFontCache(bool monospace) { for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) { if (monospace != (fs == FS_MONO)) continue; @@ -701,7 +701,7 @@ void InitFreeType(bool monospace) /** * Free everything allocated w.r.t. fonts. */ -void UninitFreeType() +void UninitFontCache() { for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) { FontCache *fc = FontCache::Get(fs); @@ -733,5 +733,5 @@ bool HasAntialiasedFonts() FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) { return FT_Err_Cannot_Open_Resource; } #endif /* WITH_FREETYPE */ -bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback) { return false; } +bool SetFallbackFont(FontCacheSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback) { return false; } #endif /* !defined(_WIN32) && !defined(__APPLE__) && !defined(WITH_FONTCONFIG) && !defined(WITH_COCOA) */ diff --git a/src/fontcache.h b/src/fontcache.h index 2eb5634cfb..aa6a02295e 100644 --- a/src/fontcache.h +++ b/src/fontcache.h @@ -212,8 +212,8 @@ static inline bool GetDrawGlyphShadow(FontSize size) return FontCache::Get(size)->GetDrawGlyphShadow(); } -/** Settings for a single freetype font. */ -struct FreeTypeSubSetting { +/** Settings for a single font. */ +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. @@ -221,18 +221,18 @@ struct FreeTypeSubSetting { const void *os_handle = nullptr; ///< Optional native OS font info. Only valid during font search. }; -/** Settings for the freetype fonts. */ -struct FreeTypeSettings { - FreeTypeSubSetting small; ///< The smallest font; mostly used for zoomed out view. - FreeTypeSubSetting medium; ///< The normal font size. - FreeTypeSubSetting large; ///< The largest font; mostly used for newspapers. - FreeTypeSubSetting mono; ///< The mono space font used for license/readme viewers. +/** Settings for the four different fonts. */ +struct FontCacheSettings { + FontCacheSubSetting small; ///< The smallest font; mostly used for zoomed out view. + FontCacheSubSetting medium; ///< The normal font size. + FontCacheSubSetting large; ///< The largest font; mostly used for newspapers. + FontCacheSubSetting mono; ///< The mono space font used for license/readme viewers. }; -extern FreeTypeSettings _freetype; +extern FontCacheSettings _fcsettings; -void InitFreeType(bool monospace); -void UninitFreeType(); +void InitFontCache(bool monospace); +void UninitFontCache(); bool HasAntialiasedFonts(); #endif /* FONTCACHE_H */ diff --git a/src/fontdetection.h b/src/fontdetection.h index 9cf39d2b07..a0242fda1f 100644 --- a/src/fontdetection.h +++ b/src/fontdetection.h @@ -37,6 +37,6 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face); * @param callback The function to call to check for missing glyphs. * @return true if a font has been set, false otherwise. */ -bool SetFallbackFont(struct FreeTypeSettings *settings, const char *language_isocode, int winlangid, class MissingGlyphSearcher *callback); +bool SetFallbackFont(struct FontCacheSettings *settings, const char *language_isocode, int winlangid, class MissingGlyphSearcher *callback); #endif diff --git a/src/openttd.cpp b/src/openttd.cpp index 2a61c41884..1b5e7be0ce 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -329,7 +329,7 @@ static void ShutdownGame() /* No NewGRFs were loaded when it was still bootstrapping. */ if (_game_mode != GM_BOOTSTRAP) ResetNewGRFData(); - UninitFreeType(); + UninitFontCache(); } /** @@ -705,8 +705,8 @@ int openttd_main(int argc, char *argv[]) /* enumerate language files */ InitializeLanguagePacks(); - /* Initialize the regular font for FreeType */ - InitFreeType(false); + /* Initialize the font cache */ + InitFontCache(false); /* This must be done early, since functions use the SetWindowDirty* calls */ InitWindowSystem(); diff --git a/src/os/macosx/font_osx.cpp b/src/os/macosx/font_osx.cpp index b931e7407b..90888c2015 100644 --- a/src/os/macosx/font_osx.cpp +++ b/src/os/macosx/font_osx.cpp @@ -57,7 +57,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) } if (os_err == noErr) { - Debug(freetype, 3, "Font path for {}: {}", font_name, file_path); + Debug(fontcache, 3, "Font path for {}: {}", font_name, file_path); err = FT_New_Face(_library, (const char *)file_path, 0, face); } @@ -67,7 +67,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) #endif /* WITH_FREETYPE */ -bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback) +bool SetFallbackFont(FontCacheSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback) { /* Determine fallback font using CoreText. This uses the language isocode * to find a suitable font. CoreText is available from 10.5 onwards. */ @@ -134,7 +134,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i /* Save result. */ callback->SetFontNames(settings, name); if (!callback->FindMissingGlyphs()) { - Debug(freetype, 2, "CT-Font for {}: {}", language_isocode, name); + Debug(fontcache, 2, "CT-Font for {}: {}", language_isocode, name); result = true; break; } @@ -221,7 +221,7 @@ void CoreTextFontCache::SetFontSize(int pixels) CFStringGetCString(font_name.get(), name, lengthof(name), kCFStringEncodingUTF8); this->font_name = name; - Debug(freetype, 2, "Loaded font '{}' with size {}", this->font_name, pixels); + Debug(fontcache, 2, "Loaded font '{}' with size {}", this->font_name, pixels); } GlyphID CoreTextFontCache::MapCharToGlyph(WChar key) @@ -350,13 +350,13 @@ void LoadCoreTextFont(FontSize fs) { static const char *SIZE_TO_NAME[] = { "medium", "small", "large", "mono" }; - FreeTypeSubSetting *settings = nullptr; + FontCacheSubSetting *settings = nullptr; switch (fs) { default: NOT_REACHED(); - case FS_SMALL: settings = &_freetype.small; break; - case FS_NORMAL: settings = &_freetype.medium; break; - case FS_LARGE: settings = &_freetype.large; break; - case FS_MONO: settings = &_freetype.mono; break; + case FS_SMALL: settings = &_fcsettings.small; break; + case FS_NORMAL: settings = &_fcsettings.medium; break; + case FS_LARGE: settings = &_fcsettings.large; break; + case FS_MONO: settings = &_fcsettings.mono; break; } if (settings->font.empty()) return; diff --git a/src/os/unix/font_unix.cpp b/src/os/unix/font_unix.cpp index 246d65e63f..98543c1bdc 100644 --- a/src/os/unix/font_unix.cpp +++ b/src/os/unix/font_unix.cpp @@ -94,7 +94,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) #endif /* WITH_FREETYPE */ -bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback) +bool SetFallbackFont(FontCacheSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback) { if (!FcInit()) return false; @@ -148,7 +148,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i callback->SetFontNames(settings, (const char *)file); bool missing = callback->FindMissingGlyphs(); - Debug(freetype, 1, "Font \"{}\" misses{} glyphs", file, missing ? "" : " no"); + Debug(fontcache, 1, "Font \"{}\" misses{} glyphs", file, missing ? "" : " no"); if (!missing) { best_weight = value; @@ -159,7 +159,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i if (best_font != nullptr) { ret = true; callback->SetFontNames(settings, best_font); - InitFreeType(callback->Monospace()); + InitFontCache(callback->Monospace()); } /* Clean up the list of filenames. */ diff --git a/src/os/windows/font_win32.cpp b/src/os/windows/font_win32.cpp index f57921c42d..6f604f8187 100644 --- a/src/os/windows/font_win32.cpp +++ b/src/os/windows/font_win32.cpp @@ -78,7 +78,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, FONT_DIR_NT, 0, KEY_READ, &hKey); if (ret != ERROR_SUCCESS) { - Debug(freetype, 0, "Cannot open registry key HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"); + Debug(fontcache, 0, "Cannot open registry key HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"); return err; } @@ -113,7 +113,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face) } if (!SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_FONTS, nullptr, SHGFP_TYPE_CURRENT, vbuffer))) { - Debug(freetype, 0, "SHGetFolderPath cannot return fonts directory"); + Debug(fontcache, 0, "SHGetFolderPath cannot return fonts directory"); goto folder_error; } @@ -268,7 +268,7 @@ public: }; struct EFCParam { - FreeTypeSettings *settings; + FontCacheSettings *settings; LOCALESIGNATURE locale; MissingGlyphSearcher *callback; FontList fonts; @@ -334,17 +334,17 @@ static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *logfont, const NEWTEXT info->callback->SetFontNames(info->settings, font_name, &logfont->elfLogFont); if (info->callback->FindMissingGlyphs()) return 1; - Debug(freetype, 1, "Fallback font: {} ({})", font_name, english_name); + Debug(fontcache, 1, "Fallback font: {} ({})", font_name, english_name); return 0; // stop enumerating } -bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback) +bool SetFallbackFont(FontCacheSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback) { - Debug(freetype, 1, "Trying fallback fonts"); + Debug(fontcache, 1, "Trying fallback fonts"); EFCParam langInfo; if (GetLocaleInfo(MAKELCID(winlangid, SORT_DEFAULT), LOCALE_FONTSIGNATURE, (LPTSTR)&langInfo.locale, sizeof(langInfo.locale) / sizeof(wchar_t)) == 0) { /* Invalid langid or some other mysterious error, can't determine fallback font. */ - Debug(freetype, 1, "Can't get locale info for fallback font (langid=0x{:x})", winlangid); + Debug(fontcache, 1, "Can't get locale info for fallback font (langid=0x{:x})", winlangid); return false; } langInfo.settings = settings; @@ -439,7 +439,7 @@ void Win32FontCache::SetFontSize(FontSize fs, int pixels) this->glyph_size.cx = otm->otmTextMetrics.tmMaxCharWidth; this->glyph_size.cy = otm->otmTextMetrics.tmHeight; - Debug(freetype, 2, "Loaded font '{}' with size {}", FS2OTTD((LPWSTR)((BYTE *)otm + (ptrdiff_t)otm->otmpFullName)), pixels); + Debug(fontcache, 2, "Loaded font '{}' with size {}", FS2OTTD((LPWSTR)((BYTE *)otm + (ptrdiff_t)otm->otmpFullName)), pixels); } /** @@ -579,12 +579,12 @@ void LoadWin32Font(FontSize fs) { static const char *SIZE_TO_NAME[] = { "medium", "small", "large", "mono" }; - FreeTypeSubSetting *settings = nullptr; + FontCacheSubSetting *settings = nullptr; switch (fs) { - case FS_SMALL: settings = &_freetype.small; break; - case FS_NORMAL: settings = &_freetype.medium; break; - case FS_LARGE: settings = &_freetype.large; break; - case FS_MONO: settings = &_freetype.mono; break; + case FS_SMALL: settings = &_fcsettings.small; break; + case FS_NORMAL: settings = &_fcsettings.medium; break; + case FS_LARGE: settings = &_fcsettings.large; break; + case FS_MONO: settings = &_fcsettings.mono; break; default: NOT_REACHED(); } diff --git a/src/strings.cpp b/src/strings.cpp index bfbde9b0dc..c589b0eef5 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -2011,7 +2011,7 @@ const char *GetCurrentLanguageIsoCode() */ bool MissingGlyphSearcher::FindMissingGlyphs() { - InitFreeType(this->Monospace()); + InitFontCache(this->Monospace()); const Sprite *question_mark[FS_END]; for (FontSize size = this->Monospace() ? FS_MONO : FS_BEGIN; size < (this->Monospace() ? FS_END : FS_MONO); size++) { @@ -2036,7 +2036,7 @@ bool MissingGlyphSearcher::FindMissingGlyphs() default: NOT_REACHED(); } - Debug(freetype, 0, "Font is missing glyphs to display char 0x{:X} in {} font size", (int)c, size_name); + Debug(fontcache, 0, "Font is missing glyphs to display char 0x{:X} in {} font size", (int)c, size_name); return true; } } @@ -2080,7 +2080,7 @@ class LanguagePackGlyphSearcher : public MissingGlyphSearcher { return false; } - void SetFontNames(FreeTypeSettings *settings, const char *font_name, const void *os_data) override + void SetFontNames(FontCacheSettings *settings, const char *font_name, const void *os_data) override { #if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA) settings->small.font = font_name; @@ -2116,15 +2116,15 @@ void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher) if (bad_font) { /* We found an unprintable character... lets try whether we can find * a fallback font that can print the characters in the current language. */ - bool any_font_configured = !_freetype.medium.font.empty(); - FreeTypeSettings backup = _freetype; + bool any_font_configured = !_fcsettings.medium.font.empty(); + FontCacheSettings backup = _fcsettings; - _freetype.mono.os_handle = nullptr; - _freetype.medium.os_handle = nullptr; + _fcsettings.mono.os_handle = nullptr; + _fcsettings.medium.os_handle = nullptr; - bad_font = !SetFallbackFont(&_freetype, _langpack.langpack->isocode, _langpack.langpack->winlangid, searcher); + bad_font = !SetFallbackFont(&_fcsettings, _langpack.langpack->isocode, _langpack.langpack->winlangid, searcher); - _freetype = backup; + _fcsettings = backup; if (!bad_font && any_font_configured) { /* If the user configured a bad font, and we found a better one, @@ -2143,7 +2143,7 @@ void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher) /* Our fallback font does miss characters too, so keep the * user chosen font as that is more likely to be any good than * the wild guess we made */ - InitFreeType(searcher->Monospace()); + InitFontCache(searcher->Monospace()); } } #endif diff --git a/src/strings_func.h b/src/strings_func.h index e9b9f81598..9d41ecd28a 100644 --- a/src/strings_func.h +++ b/src/strings_func.h @@ -273,7 +273,7 @@ public: * @param font_name The new font name. * @param os_data Opaque pointer to OS-specific data. */ - virtual void SetFontNames(struct FreeTypeSettings *settings, const char *font_name, const void *os_data = nullptr) = 0; + virtual void SetFontNames(struct FontCacheSettings *settings, const char *font_name, const void *os_data = nullptr) = 0; bool FindMissingGlyphs(); }; diff --git a/src/table/settings/misc_settings.ini b/src/table/settings/misc_settings.ini index 5d585496de..15e9413ed2 100644 --- a/src/table/settings/misc_settings.ini +++ b/src/table/settings/misc_settings.ini @@ -181,35 +181,35 @@ def = false ifdef = HAS_TRUETYPE_FONT name = ""small_font"" type = SLE_STR -var = _freetype.small.font +var = _fcsettings.small.font def = nullptr [SDTG_SSTR] ifdef = HAS_TRUETYPE_FONT name = ""medium_font"" type = SLE_STR -var = _freetype.medium.font +var = _fcsettings.medium.font def = nullptr [SDTG_SSTR] ifdef = HAS_TRUETYPE_FONT name = ""large_font"" type = SLE_STR -var = _freetype.large.font +var = _fcsettings.large.font def = nullptr [SDTG_SSTR] ifdef = HAS_TRUETYPE_FONT name = ""mono_font"" type = SLE_STR -var = _freetype.mono.font +var = _fcsettings.mono.font def = nullptr [SDTG_VAR] ifdef = HAS_TRUETYPE_FONT name = ""small_size"" type = SLE_UINT -var = _freetype.small.size +var = _fcsettings.small.size def = 0 min = 0 max = 72 @@ -218,7 +218,7 @@ max = 72 ifdef = HAS_TRUETYPE_FONT name = ""medium_size"" type = SLE_UINT -var = _freetype.medium.size +var = _fcsettings.medium.size def = 0 min = 0 max = 72 @@ -227,7 +227,7 @@ max = 72 ifdef = HAS_TRUETYPE_FONT name = ""large_size"" type = SLE_UINT -var = _freetype.large.size +var = _fcsettings.large.size def = 0 min = 0 max = 72 @@ -236,7 +236,7 @@ max = 72 ifdef = HAS_TRUETYPE_FONT name = ""mono_size"" type = SLE_UINT -var = _freetype.mono.size +var = _fcsettings.mono.size def = 0 min = 0 max = 72 @@ -244,25 +244,25 @@ max = 72 [SDTG_BOOL] ifdef = HAS_TRUETYPE_FONT name = ""small_aa"" -var = _freetype.small.aa +var = _fcsettings.small.aa def = false [SDTG_BOOL] ifdef = HAS_TRUETYPE_FONT name = ""medium_aa"" -var = _freetype.medium.aa +var = _fcsettings.medium.aa def = false [SDTG_BOOL] ifdef = HAS_TRUETYPE_FONT name = ""large_aa"" -var = _freetype.large.aa +var = _fcsettings.large.aa def = false [SDTG_BOOL] ifdef = HAS_TRUETYPE_FONT name = ""mono_aa"" -var = _freetype.mono.aa +var = _fcsettings.mono.aa def = false [SDTG_VAR] diff --git a/src/table/unicode.h b/src/table/unicode.h index 882fcb5696..5e142a88f7 100644 --- a/src/table/unicode.h +++ b/src/table/unicode.h @@ -17,7 +17,7 @@ static const byte CLRA = 0; ///< Identifier to clear all glyphs at this codepoin /* Default unicode mapping table for sprite based glyphs. * This table allows us use unicode characters even though the glyphs don't * exist, or are in the wrong place, in the standard sprite fonts. - * This is not used for FreeType rendering */ + * This is not used for TrueType rendering */ static const DefaultUnicodeMapping _default_unicode_map[] = { { 0x00A0, 0x20 }, // Non-breaking space / Up arrow diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index e9223af70a..2e8ff58515 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -215,7 +215,7 @@ void TextfileWindow::SetupScrollbars(bool force_reflow) return true; } -/* virtual */ void TextfileWindow::SetFontNames(FreeTypeSettings *settings, const char *font_name, const void *os_data) +/* virtual */ void TextfileWindow::SetFontNames(FontCacheSettings *settings, const char *font_name, const void *os_data) { #if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA) settings->mono.font = font_name; diff --git a/src/textfile_gui.h b/src/textfile_gui.h index 5f1db14ca9..f2ec9346b2 100644 --- a/src/textfile_gui.h +++ b/src/textfile_gui.h @@ -52,7 +52,7 @@ struct TextfileWindow : public Window, MissingGlyphSearcher { FontSize DefaultSize() override; const char *NextString() override; bool Monospace() override; - void SetFontNames(FreeTypeSettings *settings, const char *font_name, const void *os_data) override; + void SetFontNames(FontCacheSettings *settings, const char *font_name, const void *os_data) override; virtual void LoadTextfile(const char *textfile, Subdirectory dir);