Fix #12738, de16655f: Fallback font searcher failure since ? substitution removed.

Fallback font searcher looked for the substituted ? glyph, which was removed by #12736.

Instead of comparing against a sprite, test against the font returning a missing glyph.

This should also improve performance of fallback font searching, as previously glyphs were actually rendered while searching.
This commit is contained in:
Peter Nelson 2024-05-31 20:26:20 +01:00 committed by Peter Nelson
parent 5bca185923
commit 7e914a0568

View File

@ -2158,23 +2158,20 @@ const char *GetCurrentLanguageIsoCode()
bool MissingGlyphSearcher::FindMissingGlyphs()
{
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++) {
question_mark[size] = GetGlyph(size, '?');
}
this->Reset();
for (auto text = this->NextString(); text.has_value(); text = this->NextString()) {
auto src = text->cbegin();
FontSize size = this->DefaultSize();
FontCache *fc = FontCache::Get(size);
while (src != text->cend()) {
char32_t c = Utf8Consume(src);
if (c >= SCC_FIRST_FONT && c <= SCC_LAST_FONT) {
size = (FontSize)(c - SCC_FIRST_FONT);
} else if (!IsInsideMM(c, SCC_SPRITE_START, SCC_SPRITE_END) && IsPrintable(c) && !IsTextDirectionChar(c) && c != '?' && GetGlyph(size, c) == question_mark[size]) {
fc = FontCache::Get(size);
} 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. */
std::string size_name;