From 61a299bc992d38c1b0576cc9c3747792821ee9d7 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Mon, 14 Jul 2025 13:28:10 +0100 Subject: [PATCH] Codechange: Use SpriteID as GlyphID for SpriteFontCache. (#14439) This reduces the amount of lookups in the character map as rendering a cached layout no longer needs to do so. --- src/fontcache/spritefontcache.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fontcache/spritefontcache.cpp b/src/fontcache/spritefontcache.cpp index 962bff7851..cb49ad2817 100644 --- a/src/fontcache/spritefontcache.cpp +++ b/src/fontcache/spritefontcache.cpp @@ -103,14 +103,14 @@ void SpriteFontCache::ClearFontCache() const Sprite *SpriteFontCache::GetGlyph(GlyphID key) { - SpriteID sprite = this->GetUnicodeGlyph(static_cast(key & ~SPRITE_GLYPH)); + SpriteID sprite = static_cast(key & ~SPRITE_GLYPH); if (sprite == 0) sprite = this->GetUnicodeGlyph('?'); return GetSprite(sprite, SpriteType::Font); } uint SpriteFontCache::GetGlyphWidth(GlyphID key) { - SpriteID sprite = this->GetUnicodeGlyph(static_cast(key & ~SPRITE_GLYPH)); + SpriteID sprite = static_cast(key & ~SPRITE_GLYPH); if (sprite == 0) sprite = this->GetUnicodeGlyph('?'); return SpriteExists(sprite) ? GetSprite(sprite, SpriteType::Font)->width + ScaleFontTrad(this->fs != FS_NORMAL ? 1 : 0) : 0; } @@ -120,7 +120,7 @@ GlyphID SpriteFontCache::MapCharToGlyph(char32_t key, [[maybe_unused]] bool allo assert(IsPrintable(key)); SpriteID sprite = this->GetUnicodeGlyph(key); if (sprite == 0) return 0; - return SPRITE_GLYPH | key; + return SPRITE_GLYPH | sprite; } bool SpriteFontCache::GetDrawGlyphShadow()