11#include "../fontcache.h"
12#include "../gfx_layout.h"
13#include "../zoom_func.h"
16#include "../table/sprites.h"
17#include "../table/control_codes.h"
18#include "../table/unicode.h"
20#include "../safeguards.h"
69 default: NOT_REACHED();
71 case FS_NORMAL: base = SPR_ASCII_SPACE;
break;
72 case FS_SMALL: base = SPR_ASCII_SPACE_SMALL;
break;
73 case FS_LARGE: base = SPR_ASCII_SPACE_BIG;
break;
78 if (!SpriteExists(sprite))
continue;
83 for (
const auto &unicode_map : _default_unicode_map) {
84 uint8_t key = unicode_map.key;
120 assert(IsPrintable(key));
122 if (sprite == 0)
return 0;
123 return SPRITE_GLYPH | key;
Font cache for basic fonts.
int height
The height of the font.
const FontSize fs
The size of the font.
int ascender
The ascender value of the font.
static void ResetFontCache(FontSize size)
Reset cached font information.
SpriteFontCache(FontSize fs)
Create a new sprite font cache.
uint GetGlyphWidth(GlyphID key) override
Get the width of the glyph with the given key.
void InitializeUnicodeGlyphMap() override
Initialize the glyph map.
GlyphID MapCharToGlyph(char32_t key, bool allow_fallback=true) override
Map a character into a glyph.
SpriteID GetUnicodeGlyph(GlyphID key)
Get SpriteID associated with a GlyphID.
std::unordered_map< GlyphID, SpriteID > glyph_to_spriteid_map
Mapping of glyphs to sprite IDs.
bool GetDrawGlyphShadow() override
Do we need to draw a glyph shadow?
void SetUnicodeGlyph(char32_t key, SpriteID sprite) override
Map a SpriteID to the key.
void ClearFontCache() override
Clear the font cache.
const Sprite * GetGlyph(GlyphID key) override
Get the glyph (sprite) of the given key.
uint32_t GlyphID
Glyphs are characters from a font.
ZoomLevel _font_zoom
Sprite font Zoom level (not clamped)
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
@ Font
A sprite used for fonts.
FontSize
Available font sizes.
@ FS_MONO
Index of the monospaced font in the font tables.
@ FS_SMALL
Index of the small font in the font tables.
@ FS_NORMAL
Index of the normal font in the font tables.
@ FS_LARGE
Index of the large font in the font tables.
static int ScaleFontTrad(int value)
Scale traditional pixel dimensions to font zoom level, for drawing sprite fonts.
static const int ASCII_LETTERSTART
First printable ASCII letter.
Sprite font cache implementation definition.
Data structure describing a sprite.
uint16_t width
Width of the sprite.
static const uint8_t CLRA
Identifier to clear all glyphs at this codepoint.
int UnScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_MIN) When shifting right,...