OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
10 #include "../stdafx.h"
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;
const Sprite * GetGlyph(GlyphID key) override
Get the glyph (sprite) of the given key.
int height
The height of the font.
uint GetGlyphWidth(GlyphID key) override
Get the width of the glyph with the given key.
void InitializeUnicodeGlyphMap() override
Initialize the glyph map.
@ FS_LARGE
Index of the large font in the font tables.
static const uint8_t CLRA
Identifier to clear all glyphs at this codepoint.
static void ResetFontCache(FontSize size)
Reset cached font information.
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
void SetUnicodeGlyph(char32_t key, SpriteID sprite) override
Map a SpriteID to the key.
GlyphID MapCharToGlyph(char32_t key, bool allow_fallback=true) override
Map a character into a glyph.
@ FS_NORMAL
Index of the normal font in the font tables.
@ FS_SMALL
Index of the small font in the font tables.
uint16_t width
Width of the sprite.
bool GetDrawGlyphShadow() override
Do we need to draw a glyph shadow?
uint32_t GlyphID
Glyphs are characters from a font.
const FontSize fs
The size of the font.
std::unordered_map< GlyphID, SpriteID > glyph_to_spriteid_map
Mapping of glyphs to sprite IDs.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
ZoomLevel _font_zoom
Sprite font Zoom level (not clamped)
void ClearFontCache() override
Clear the font cache.
int UnScaleByZoom(int value, ZoomLevel zoom)
Scale by zoom level, usually shift right (when zoom > ZOOM_LVL_MIN) When shifting right,...
Font cache for basic fonts.
static const int ASCII_LETTERSTART
First printable ASCII letter.
SpriteID GetUnicodeGlyph(GlyphID key)
Get SpriteID associated with a GlyphID.
int ascender
The ascender value of the font.
@ FS_MONO
Index of the monospaced font in the font tables.
static int ScaleFontTrad(int value)
Scale traditional pixel dimensions to font zoom level, for drawing sprite fonts.
@ Font
A sprite used for fonts.
FontSize
Available font sizes.
SpriteFontCache(FontSize fs)
Create a new sprite font cache.
Data structure describing a sprite.