mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2026-07-22 18:49:40 +00:00
Codechange: MissingGlyphSearcher now contains which fontsizes to search for
This commit is contained in:
committed by
Peter Nelson
parent
3c9a75a387
commit
cdfbb113ce
+13
-26
@@ -2312,7 +2312,7 @@ std::string_view GetCurrentLanguageIsoCode()
|
||||
*/
|
||||
bool MissingGlyphSearcher::FindMissingGlyphs()
|
||||
{
|
||||
FontCache::LoadFontCaches(this->Monospace() ? FontSizes{FS_MONO} : FONTSIZES_REQUIRED);
|
||||
FontCache::LoadFontCaches(this->fontsizes);
|
||||
|
||||
this->Reset();
|
||||
for (auto text = this->NextString(); text.has_value(); text = this->NextString()) {
|
||||
@@ -2325,6 +2325,10 @@ bool MissingGlyphSearcher::FindMissingGlyphs()
|
||||
} else if (!IsInsideMM(c, SCC_SPRITE_START, SCC_SPRITE_END) && IsPrintable(c) && !IsTextDirectionChar(c) && fc->MapCharToGlyph(c, false) == 0) {
|
||||
/* The character is printable, but not in the normal font. This is the case we were testing for. */
|
||||
Debug(fontcache, 0, "Font is missing glyphs to display char 0x{:X} in {} font size", static_cast<uint32_t>(c), FontSizeToName(size));
|
||||
|
||||
/* For now, assume all fontsizes need searching if any are missing. */
|
||||
this->missing_fontsizes = this->fontsizes;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2334,6 +2338,10 @@ bool MissingGlyphSearcher::FindMissingGlyphs()
|
||||
|
||||
/** Helper for searching through the language pack. */
|
||||
class LanguagePackGlyphSearcher : public MissingGlyphSearcher {
|
||||
public:
|
||||
LanguagePackGlyphSearcher() : MissingGlyphSearcher(FONTSIZES_REQUIRED) {}
|
||||
|
||||
private:
|
||||
uint i; ///< Iterator for the primary language tables.
|
||||
uint j; ///< Iterator for the secondary language tables.
|
||||
|
||||
@@ -2362,24 +2370,6 @@ class LanguagePackGlyphSearcher : public MissingGlyphSearcher {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Monospace() override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void SetFontNames([[maybe_unused]] FontCacheSettings *settings, [[maybe_unused]] std::string_view font_name, [[maybe_unused]] const void *os_data) override
|
||||
{
|
||||
#if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
|
||||
settings->small.font = font_name;
|
||||
settings->medium.font = font_name;
|
||||
settings->large.font = font_name;
|
||||
|
||||
settings->small.os_handle = os_data;
|
||||
settings->medium.os_handle = os_data;
|
||||
settings->large.os_handle = os_data;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -2406,10 +2396,7 @@ void CheckForMissingGlyphs(MissingGlyphSearcher *searcher)
|
||||
bool any_font_configured = !_fcsettings.medium.font.empty();
|
||||
FontCacheSettings backup = _fcsettings;
|
||||
|
||||
_fcsettings.mono.os_handle = nullptr;
|
||||
_fcsettings.medium.os_handle = nullptr;
|
||||
|
||||
bad_font = !FontProviderManager::FindFallbackFont(&_fcsettings, _langpack.langpack->isocode, searcher);
|
||||
bad_font = !FontProviderManager::FindFallbackFont(_langpack.langpack->isocode, searcher);
|
||||
|
||||
_fcsettings = std::move(backup);
|
||||
|
||||
@@ -2428,7 +2415,7 @@ void CheckForMissingGlyphs(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 */
|
||||
FontCache::LoadFontCaches(searcher->Monospace() ? FontSizes{FS_MONO} : FONTSIZES_REQUIRED);
|
||||
FontCache::LoadFontCaches(searcher->fontsizes);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -2445,12 +2432,12 @@ void CheckForMissingGlyphs(MissingGlyphSearcher *searcher)
|
||||
ShowErrorMessage(GetEncodedString(STR_JUST_RAW_STRING, std::move(err_str)), {}, WL_WARNING);
|
||||
|
||||
/* Reset the font width */
|
||||
LoadStringWidthTable(searcher->Monospace() ? FontSizes{FS_MONO} : FONTSIZES_REQUIRED);
|
||||
LoadStringWidthTable(searcher->fontsizes);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Update the font with cache */
|
||||
LoadStringWidthTable(searcher->Monospace() ? FontSizes{FS_MONO} : FONTSIZES_REQUIRED);
|
||||
LoadStringWidthTable(searcher->fontsizes);
|
||||
|
||||
#if !(defined(WITH_ICU_I18N) && defined(WITH_HARFBUZZ)) && !defined(WITH_UNISCRIBE) && !defined(WITH_COCOA)
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user