mirror of https://github.com/OpenTTD/OpenTTD
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.pull/12740/head
parent
5bca185923
commit
7e914a0568
|
@ -2158,23 +2158,20 @@ const char *GetCurrentLanguageIsoCode()
|
||||||
bool MissingGlyphSearcher::FindMissingGlyphs()
|
bool MissingGlyphSearcher::FindMissingGlyphs()
|
||||||
{
|
{
|
||||||
InitFontCache(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++) {
|
|
||||||
question_mark[size] = GetGlyph(size, '?');
|
|
||||||
}
|
|
||||||
|
|
||||||
this->Reset();
|
this->Reset();
|
||||||
for (auto text = this->NextString(); text.has_value(); text = this->NextString()) {
|
for (auto text = this->NextString(); text.has_value(); text = this->NextString()) {
|
||||||
auto src = text->cbegin();
|
auto src = text->cbegin();
|
||||||
|
|
||||||
FontSize size = this->DefaultSize();
|
FontSize size = this->DefaultSize();
|
||||||
|
FontCache *fc = FontCache::Get(size);
|
||||||
while (src != text->cend()) {
|
while (src != text->cend()) {
|
||||||
char32_t c = Utf8Consume(src);
|
char32_t c = Utf8Consume(src);
|
||||||
|
|
||||||
if (c >= SCC_FIRST_FONT && c <= SCC_LAST_FONT) {
|
if (c >= SCC_FIRST_FONT && c <= SCC_LAST_FONT) {
|
||||||
size = (FontSize)(c - SCC_FIRST_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. */
|
/* The character is printable, but not in the normal font. This is the case we were testing for. */
|
||||||
std::string size_name;
|
std::string size_name;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue