| 48 | }; |
| 49 | |
| 50 | struct FontStack { |
| 51 | OptionalClxSpriteList baseFont; |
| 52 | OptionalClxSpriteList overrideFont; |
| 53 | |
| 54 | FontStack() = default; |
| 55 | |
| 56 | explicit FontStack(const OwnedFontStack &owned) |
| 57 | { |
| 58 | if (owned.baseFont.has_value()) baseFont.emplace(*owned.baseFont); |
| 59 | if (owned.overrideFont.has_value()) overrideFont.emplace(*owned.overrideFont); |
| 60 | } |
| 61 | |
| 62 | [[nodiscard]] bool has_value() const // NOLINT(readability-identifier-naming) |
| 63 | { |
| 64 | return baseFont.has_value() || overrideFont.has_value(); |
| 65 | } |
| 66 | |
| 67 | [[nodiscard]] ClxSprite glyph(size_t i) const |
| 68 | { |
| 69 | if (overrideFont.has_value()) { |
| 70 | ClxSprite overrideGlyph = (*overrideFont)[i]; |
| 71 | if (overrideGlyph.width() != 0) return overrideGlyph; |
| 72 | } |
| 73 | return (*baseFont)[i]; |
| 74 | } |
| 75 | }; |
| 76 | |
| 77 | std::unordered_map<uint32_t, OwnedFontStack> Fonts; |
| 78 | |