* Initialize the glyph map for a font size. * This populates the glyph map with the baseset font sprites. * @param fs Font size to initialize. */
| 64 | * @param fs Font size to initialize. |
| 65 | */ |
| 66 | void InitializeUnicodeGlyphMap(FontSize fs) |
| 67 | { |
| 68 | /* Clear out existing glyph map if it exists */ |
| 69 | _char_maps[fs].clear(); |
| 70 | |
| 71 | SpriteID base; |
| 72 | switch (fs) { |
| 73 | default: NOT_REACHED(); |
| 74 | case FS_MONO: // Use normal as default for mono spaced font |
| 75 | case FS_NORMAL: base = SPR_ASCII_SPACE; break; |
| 76 | case FS_SMALL: base = SPR_ASCII_SPACE_SMALL; break; |
| 77 | case FS_LARGE: base = SPR_ASCII_SPACE_BIG; break; |
| 78 | } |
| 79 | |
| 80 | for (uint i = ASCII_LETTERSTART; i < 256; i++) { |
| 81 | SpriteID sprite = base + i - ASCII_LETTERSTART; |
| 82 | if (!SpriteExists(sprite)) continue; |
| 83 | SetUnicodeGlyph(fs, i, sprite); |
| 84 | SetUnicodeGlyph(fs, i + SCC_SPRITE_START, sprite); |
| 85 | } |
| 86 | |
| 87 | /* Modify map to move non-standard glyphs to a better unicode codepoint. */ |
| 88 | for (const auto &unicode_map : _default_unicode_map) { |
| 89 | uint8_t key = unicode_map.key; |
| 90 | if (key == CLRA) { |
| 91 | /* Clear the glyph. This happens if the glyph at this code point |
| 92 | * is non-standard and should be accessed by an SCC_xxx enum |
| 93 | * entry only. */ |
| 94 | SetUnicodeGlyph(fs, unicode_map.code, 0); |
| 95 | } else { |
| 96 | SpriteID sprite = base + key - ASCII_LETTERSTART; |
| 97 | if (!SpriteExists(sprite)) continue; |
| 98 | SetUnicodeGlyph(fs, unicode_map.code, sprite); |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Initialize the glyph map. |
no test coverage detected