27static 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])
51int FontCache::GetDefaultFontHeight(
FontSize fs)
85 void FontCache::InitializeFontCaches()
101void SetFont(
FontSize fontsize,
const std::string &font, uint size)
104 bool changed =
false;
106 if (setting->
font != font) {
107 setting->
font = font;
111 if (setting->
size != size) {
112 setting->
size = size;
116 if (!changed)
return;
122 if (fs == fontsize)
continue;
127 _fcsettings = backup;
144#elif defined(WITH_COCOA)
165 return IsDefaultFont(setting) ? FontCache::GetDefaultFontHeight(fs) : setting.
size;
168#if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
177 case FS_NORMAL:
return "OpenTTD-Sans.ttf";
178 case FS_SMALL:
return "OpenTTD-Small.ttf";
179 case FS_LARGE:
return "OpenTTD-Serif.ttf";
180 case FS_MONO:
return "OpenTTD-Mono.ttf";
181 default: NOT_REACHED();
193#if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA)
220 FontCache::InitializeFontCaches();
223 if (monospace != (fs ==
FS_MONO))
continue;
232#elif defined(WITH_COCOA)
253#if !defined(_WIN32) && !defined(__APPLE__) && !defined(WITH_FONTCONFIG) && !defined(WITH_COCOA)
void UpdateAllVirtCoords()
Update the viewport coordinates of all signs.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
Font cache for basic fonts.
virtual std::string GetFontName()=0
Get the name of this font.
int GetHeight() const
Get the height of the font.
FontCache * parent
The parent of this font cache.
bool HasParent()
Check whether the font cache has a parent.
static FontCache * caches[FS_END]
All the font caches.
FontCache(FontSize fs)
Create a new font cache.
virtual ~FontCache()
Clean everything up.
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 * Get(FontSize fs)
Get the font cache of a given font size.
static void ResetFontCache(FontSize size)
Reset cached font information.
A searcher for missing glyphs.
Font cache for fonts that are based on a freetype font.
Factory to 'query' all available blitters.
std::string FioFindFullPath(Subdirectory subdir, const std::string &filename)
Find a path to the filename in one of the search directories.
Functions for Standard In/Out file operations.
@ BASESET_DIR
Subdirectory for all base data (base sets, intro game)
fluid_settings_t * settings
FluidSynth settings handle.
void LoadCoreTextFont(FontSize fs)
Loads the TrueType font.
void LoadWin32Font(FontSize fs)
Loads the GDI font.
void InitFontCache(bool monospace)
(Re)initialize the font cache related things, i.e.
void UninitFreeType()
Free everything allocated w.r.t.
void LoadFreeTypeFont(FontSize fs)
Loads the freetype font.
static const int _default_font_height[FS_END]
Default heights for the different sizes of fonts.
void UninitFontCache()
Free everything allocated w.r.t.
static std::string GetDefaultTruetypeFontFile(FontSize fs)
Get path of default font file for a given font size.
uint GetFontCacheFontSize(FontSize fs)
Get the scalable font size to use for a FontSize.
static bool IsDefaultFont(const FontCacheSubSetting &setting)
Test if a font setting uses the default font.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
std::string GetFontCacheFontName(FontSize fs)
Get font to use for a given font size.
static std::string GetDefaultTruetypeFont(FontSize fs)
Get name of default font file for a given font size.
Functions to read fonts from files and cache them.
FontCacheSubSetting * GetFontCacheSubSetting(FontSize fs)
Get the settings of a given font size.
Functions related to detecting/finding the right font.
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.
void LoadStringWidthTable(bool monospace)
Initialize _stringwidth_table cache.
Functions related to laying out the texts.
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.
A number of safeguards to prevent using unsafe methods.
void SaveToConfig()
Save the values to the configuration file.
Functions related to setting/changing the settings.
Sprite font cache implementation definition.
Definition of base types and functions in a cross-platform compatible way.
void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
Check whether the currently loaded language pack uses characters that the currently loaded font does ...
Functions related to OTTD's strings.
Settings for the four different fonts.
bool prefer_sprite
Whether to prefer the built-in sprite font over resizable fonts.
bool global_aa
Whether to anti alias all font sizes.
Settings for a single font.
std::string font
The name of the font, or path to the font.
uint size
The (requested) size of the font.
const void * os_handle
Optional native OS font info. Only valid during font search.
Functions related to (drawing on) viewports.
void ReInitAllWindows(bool zoom_changed)
Re-initialize all windows.
Window functions not directly related to making/drawing windows.