OpenTTD Source 20250905-master-g122023be8d
|
Sprite fontcache implementation. More...
#include "../stdafx.h"
#include "../fontcache.h"
#include "../gfx_layout.h"
#include "../string_func.h"
#include "../zoom_func.h"
#include "spritefontcache.h"
#include "../table/sprites.h"
#include "../table/control_codes.h"
#include "../table/unicode.h"
#include "../safeguards.h"
Go to the source code of this file.
Data Structures | |
class | SpriteFontCacheFactory |
Functions | |
static int | ScaleFontTrad (int value) |
Scale traditional pixel dimensions to font zoom level, for drawing sprite fonts. | |
static SpriteID | GetUnicodeGlyph (FontSize fs, char32_t key) |
Get SpriteID associated with a character. | |
void | SetUnicodeGlyph (FontSize fs, char32_t key, SpriteID sprite) |
Set the SpriteID for a unicode character. | |
void | InitializeUnicodeGlyphMap (FontSize fs) |
Initialize the glyph map for a font size. | |
void | InitializeUnicodeGlyphMap () |
Initialize the glyph map. | |
Variables | |
static const int | ASCII_LETTERSTART = 32 |
First printable ASCII letter. | |
static std::array< std::unordered_map< char32_t, SpriteID >, FS_END > | _char_maps {} |
Glyph map for each font size. | |
Sprite fontcache implementation.
Definition in file spritefontcache.cpp.
Get SpriteID associated with a character.
key | Character to find. |
Definition at line 42 of file spritefontcache.cpp.
References _char_maps.
Referenced by SpriteFontCache::GetGlyph(), SpriteFontCache::GetGlyphWidth(), and SpriteFontCache::MapCharToGlyph().
void InitializeUnicodeGlyphMap | ( | ) |
Initialize the glyph map.
Definition at line 104 of file spritefontcache.cpp.
References FS_BEGIN, and InitializeUnicodeGlyphMap().
Referenced by HandleBootstrap(), InitializeUnicodeGlyphMap(), and LoadSpriteTables().
void InitializeUnicodeGlyphMap | ( | FontSize | fs | ) |
Initialize the glyph map for a font size.
This populates the glyph map with the baseset font sprites.
fs | Font size to initialize. |
Definition at line 65 of file spritefontcache.cpp.
References _char_maps, ASCII_LETTERSTART, CLRA, FS_LARGE, FS_MONO, FS_NORMAL, FS_SMALL, and SetUnicodeGlyph().
|
static |
Scale traditional pixel dimensions to font zoom level, for drawing sprite fonts.
value | Pixel amount at ZOOM_BASE (traditional "normal" interface size). |
Definition at line 30 of file spritefontcache.cpp.
References _font_zoom, and UnScaleByZoom().
Referenced by SpriteFontCache::ClearFontCache(), SpriteFontCache::GetGlyphWidth(), and SpriteFontCache::SpriteFontCache().
Set the SpriteID for a unicode character.
fs | Font size to set. |
key | Unicode character to set. |
sprite | SpriteID of character. |
Definition at line 55 of file spritefontcache.cpp.
References _char_maps.
Referenced by InitializeUnicodeGlyphMap(), and LoadFontGlyph().
|
static |
Glyph map for each font size.
Definition at line 35 of file spritefontcache.cpp.
Referenced by GetUnicodeGlyph(), InitializeUnicodeGlyphMap(), and SetUnicodeGlyph().
|
static |
First printable ASCII letter.
Definition at line 23 of file spritefontcache.cpp.
Referenced by InitializeUnicodeGlyphMap().