From 7546c1acabf832574ee30a3cce870a020b201420 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Mon, 14 Jul 2025 09:01:42 +0100 Subject: [PATCH] Codefix f220ed179d: GetUnicodeGlyph takes a unicode character. (#14438) Previous change erroneously changed type to GlyphID, based on naming. It should actually be char32_t. --- src/fontcache/spritefontcache.cpp | 16 ++++++++-------- src/fontcache/spritefontcache.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/fontcache/spritefontcache.cpp b/src/fontcache/spritefontcache.cpp index c9f75153b5..962bff7851 100644 --- a/src/fontcache/spritefontcache.cpp +++ b/src/fontcache/spritefontcache.cpp @@ -43,26 +43,26 @@ SpriteFontCache::SpriteFontCache(FontSize fs) : FontCache(fs) } /** - * Get SpriteID associated with a GlyphID. - * @param key Glyph to find. - * @return SpriteID of glyph, or 0 if not present. + * Get SpriteID associated with a character. + * @param key Character to find. + * @return SpriteID for character, or 0 if not present. */ -SpriteID SpriteFontCache::GetUnicodeGlyph(GlyphID key) +SpriteID SpriteFontCache::GetUnicodeGlyph(char32_t key) { - const auto found = this->glyph_to_spriteid_map.find(key & ~SPRITE_GLYPH); - if (found == std::end(this->glyph_to_spriteid_map)) return 0; + const auto found = this->char_map.find(key); + if (found == std::end(this->char_map)) return 0; return found->second; } void SpriteFontCache::SetUnicodeGlyph(char32_t key, SpriteID sprite) { - this->glyph_to_spriteid_map[key] = sprite; + this->char_map[key] = sprite; } void SpriteFontCache::InitializeUnicodeGlyphMap() { /* Clear out existing glyph map if it exists */ - this->glyph_to_spriteid_map.clear(); + this->char_map.clear(); SpriteID base; switch (this->fs) { diff --git a/src/fontcache/spritefontcache.h b/src/fontcache/spritefontcache.h index 61dd5866e2..1f2a09a9c6 100644 --- a/src/fontcache/spritefontcache.h +++ b/src/fontcache/spritefontcache.h @@ -28,8 +28,8 @@ public: bool IsBuiltInFont() override { return true; } private: - std::unordered_map glyph_to_spriteid_map{}; ///< Mapping of glyphs to sprite IDs. - SpriteID GetUnicodeGlyph(GlyphID key); + std::unordered_map char_map{}; ///< Mapping of characters to sprite IDs. + SpriteID GetUnicodeGlyph(char32_t key); }; #endif /* SPRITEFONTCACHE_H */