mirror of https://github.com/OpenTTD/OpenTTD
Codefix f220ed179d: GetUnicodeGlyph takes a unicode character. (#14438)
Previous change erroneously changed type to GlyphID, based on naming. It should actually be char32_t.pull/14439/head
parent
a6143eea21
commit
7546c1acab
|
@ -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) {
|
||||
|
|
|
@ -28,8 +28,8 @@ public:
|
|||
bool IsBuiltInFont() override { return true; }
|
||||
|
||||
private:
|
||||
std::unordered_map<GlyphID, SpriteID> glyph_to_spriteid_map{}; ///< Mapping of glyphs to sprite IDs.
|
||||
SpriteID GetUnicodeGlyph(GlyphID key);
|
||||
std::unordered_map<char32_t, SpriteID> char_map{}; ///< Mapping of characters to sprite IDs.
|
||||
SpriteID GetUnicodeGlyph(char32_t key);
|
||||
};
|
||||
|
||||
#endif /* SPRITEFONTCACHE_H */
|
||||
|
|
Loading…
Reference in New Issue