From 4438071fad0c30b77622096b4ca8f057c34139b5 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 26 Jun 2024 09:07:40 +0100 Subject: [PATCH] Fix #12815, 7e914a0568: Fallback detection failed with sprite font. How missing glyphs were detected was changed, but the sprite font still substituted `?`, which to missing glyph looked like all characters are present. --- src/fontcache/spritefontcache.cpp | 8 ++++++++ src/fontcache/spritefontcache.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/fontcache/spritefontcache.cpp b/src/fontcache/spritefontcache.cpp index 9d945d394b..c9f75153b5 100644 --- a/src/fontcache/spritefontcache.cpp +++ b/src/fontcache/spritefontcache.cpp @@ -115,6 +115,14 @@ uint SpriteFontCache::GetGlyphWidth(GlyphID key) return SpriteExists(sprite) ? GetSprite(sprite, SpriteType::Font)->width + ScaleFontTrad(this->fs != FS_NORMAL ? 1 : 0) : 0; } +GlyphID SpriteFontCache::MapCharToGlyph(char32_t key, [[maybe_unused]] bool allow_fallback) +{ + assert(IsPrintable(key)); + SpriteID sprite = this->GetUnicodeGlyph(key); + if (sprite == 0) return 0; + return SPRITE_GLYPH | key; +} + bool SpriteFontCache::GetDrawGlyphShadow() { return false; diff --git a/src/fontcache/spritefontcache.h b/src/fontcache/spritefontcache.h index 4e43b8752c..61dd5866e2 100644 --- a/src/fontcache/spritefontcache.h +++ b/src/fontcache/spritefontcache.h @@ -23,7 +23,7 @@ public: const Sprite *GetGlyph(GlyphID key) override; uint GetGlyphWidth(GlyphID key) override; bool GetDrawGlyphShadow() override; - GlyphID MapCharToGlyph(char32_t key, [[maybe_unused]] bool allow_fallback = true) override { assert(IsPrintable(key)); return SPRITE_GLYPH | key; } + GlyphID MapCharToGlyph(char32_t key, bool allow_fallback = true) override; std::string GetFontName() override { return "sprite"; } bool IsBuiltInFont() override { return true; }