|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
27 static const int _default_font_ascender[FS_END] = { 8, 5, 15, 8};
36 ascender(_default_font_ascender[fs]), descender(_default_font_ascender[fs] -
_default_font_height[fs]),
52 int FontCache::GetDefaultFontHeight(
FontSize fs)
86 void FontCache::InitializeFontCaches()
94 bool GetFontAAState(
FontSize size,
bool check_blitter)
102 void SetFont(
FontSize fontsize,
const std::string &font, uint size,
bool aa)
105 bool changed =
false;
107 if (setting->
font != font) {
108 setting->
font = font;
112 if (setting->
size != size) {
113 setting->
size = size;
117 if (setting->
aa != aa) {
122 if (!changed)
return;
128 if (fs == fontsize)
continue;
133 _fcsettings = backup;
149 #elif defined(_WIN32)
152 #elif defined(WITH_COCOA)
157 static void TryLoadDefaultTrueTypeFont([[maybe_unused]]
FontSize fs)
159 #if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
160 std::string font_name{};
163 font_name =
"OpenTTD-Sans.ttf";
166 font_name =
"OpenTTD-Small.ttf";
169 font_name =
"OpenTTD-Serif.ttf";
172 font_name =
"OpenTTD-Mono.ttf";
175 default: NOT_REACHED();
180 if (!full_font.empty()) {
181 int size = FontCache::GetDefaultFontHeight(fs);
184 #elif defined(_WIN32)
186 #elif defined(WITH_COCOA)
199 FontCache::InitializeFontCaches();
202 if (monospace != (fs ==
FS_MONO))
continue;
208 TryLoadDefaultTrueTypeFont(fs);
212 #elif defined(_WIN32)
214 #elif defined(WITH_COCOA)
243 if (!
FontCache::Get(fs)->IsBuiltInFont() && GetFontAAState(fs,
false))
return true;
249 #if !defined(_WIN32) && !defined(__APPLE__) && !defined(WITH_FONTCONFIG) && !defined(WITH_COCOA)
void LoadStringWidthTable(bool monospace)
Initialize _stringwidth_table cache.
static const int _default_font_height[FS_END]
Default heights for the different sizes of fonts.
A searcher for missing glyphs.
bool SetFallbackFont(struct FontCacheSettings *settings, const std::string &language_isocode, int winlangid, class MissingGlyphSearcher *callback)
We would like to have a fallback font as the current one doesn't contain all characters we need.
Settings for a single font.
int GetHeight() const
Get the height of the font.
std::string FioFindFullPath(Subdirectory subdir, const std::string &filename)
Find a path to the filename in one of the search directories.
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
void SaveToConfig()
Save the values to the configuration file.
bool aa
Whether to do anti aliasing or not.
@ FS_LARGE
Index of the large font in the font tables.
static void ResetFontCache(FontSize size)
Reset cached font information.
Font cache for fonts that are based on a freetype font.
uint size
The (requested) size of the font.
void UninitFontCache()
Free everything allocated w.r.t.
Settings for the four different fonts.
bool HasParent()
Check whether the font cache has a parent.
@ FS_NORMAL
Index of the normal font in the font tables.
void LoadWin32Font(FontSize fs)
Loads the GDI font.
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
std::string font
The name of the font, or path to the font.
@ FS_SMALL
Index of the small font in the font tables.
bool HasAntialiasedFonts()
Should any of the active fonts be anti-aliased?
void InitFontCache(bool monospace)
(Re)initialize the font cache related things, i.e.
bool prefer_sprite
Whether to prefer the built-in sprite font over resizable fonts.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
virtual ~FontCache()
Clean everything up.
void UninitFreeType()
Free everything allocated w.r.t.
FontCacheSubSetting * GetFontCacheSubSetting(FontSize fs)
Get the settings of a given font size.
const FontSize fs
The size of the font.
static std::string GetName(FontSize fs)
Get the font name of a given font size.
static FontCache * caches[FS_END]
All the font caches.
virtual std::string GetFontName()=0
Get the name of this font.
Font cache for basic fonts.
void UpdateAllVirtCoords()
Update the viewport coordinates of all signs.
FontCache * parent
The parent of this font cache.
void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
@ FS_MONO
Index of the monospaced font in the font tables.
FontSize
Available font sizes.
void LoadCoreTextFont(FontSize fs)
Loads the TrueType font.
void LoadFreeTypeFont(FontSize fs)
Loads the freetype font.
bool global_aa
Whether to anti alias all font sizes.
FontCache(FontSize fs)
Create a new font cache.
static FontCache * Get(FontSize fs)
Get the font cache of a given font size.