OpenTTD Source 20261112-master-gbcbec5e63f
font_win32.cpp
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#include "../../stdafx.h"
11#include "../../debug.h"
14#include "../../error_func.h"
15#include "../../fileio_func.h"
16#include "../../fontcache.h"
19#include "../../spritecache.h"
20#include "../../string_func.h"
21#include "../../strings_func.h"
22#include "../../zoom_func.h"
23#include "font_win32.h"
24
26
27#include <windows.h>
28#include <shlobj.h> /* SHGetFolderPath */
29#include "win32.h"
30#undef small // Say what, Windows?
31
32#include "../../safeguards.h"
33
34struct EFCParam {
35 LOCALESIGNATURE locale;
36 MissingGlyphSearcher *callback;
37 std::vector<std::wstring> fonts;
38
39 bool Add(const std::wstring_view &font)
40 {
41 auto it = std::ranges::find(this->fonts, font);
42 if (it != std::end(this->fonts)) return false;
43
44 this->fonts.emplace_back(font);
45
46 return true;
47 }
48};
49
50static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *logfont, const NEWTEXTMETRICEX *metric, DWORD type, LPARAM lParam)
51{
52 EFCParam *info = (EFCParam *)lParam;
53
54 /* Skip duplicates */
55 if (!info->Add(logfont->elfFullName)) return 1;
56 /* Only use TrueType fonts */
57 if (!(type & TRUETYPE_FONTTYPE)) return 1;
58 /* Don't use SYMBOL fonts */
59 if (logfont->elfLogFont.lfCharSet == SYMBOL_CHARSET) return 1;
60 /* Use monospaced fonts when asked for it. */
61 if (info->callback->missing_fontsizes.Test(FontSize::Monospace) && (logfont->elfLogFont.lfPitchAndFamily & (FF_MODERN | FIXED_PITCH)) != (FF_MODERN | FIXED_PITCH)) return 1;
62
63 /* The font has to have at least one of the supported locales to be usable. */
64 auto check_bitfields = [&]() {
65 /* First try Unicode Subset Bitfield. */
66 for (uint8_t i = 0; i < 4; i++) {
67 if ((metric->ntmFontSig.fsUsb[i] & info->locale.lsUsb[i]) != 0) return true;
68 }
69 /* Keep Code Page Bitfield as a fallback. */
70 for (uint8_t i = 0; i < 2; i++) {
71 if ((metric->ntmFontSig.fsCsb[i] & info->locale.lsCsbSupported[i]) != 0) return true;
72 }
73 return false;
74 };
75 if (!check_bitfields()) return 1;
76
77 char font_name[MAX_PATH];
78 convert_from_fs(logfont->elfFullName, font_name);
79
80 if (!FontCache::TryFallback(info->callback->missing_fontsizes, info->callback->required_glyphs, font_name, logfont->elfLogFont)) return 1;
81
82 FontCache::AddFallback(info->callback->missing_fontsizes, font_name, logfont->elfLogFont);
83 Debug(Facility::Fontcache, Severity::Error, "Fallback font: {}", font_name);
84 return 0; // stop enumerating
85}
86
94{
95 this->dc = CreateCompatibleDC(nullptr);
96 this->SetFontSize(pixels);
97}
98
101{
102 this->ClearFontCache();
103 DeleteDC(this->dc);
104 DeleteObject(this->font);
105}
106
107void Win32FontCache::SetFontSize(int pixels)
108{
109 if (pixels == 0) {
110 /* Try to determine a good height based on the minimal height recommended by the font. */
111 int scaled_height = ScaleGUITrad(FontCache::GetDefaultFontHeight(this->fs));
112 pixels = scaled_height;
113
114 HFONT temp = CreateFontIndirect(&this->logfont);
115 if (temp != nullptr) {
116 HGDIOBJ old = SelectObject(this->dc, temp);
117
118 UINT size = GetOutlineTextMetrics(this->dc, 0, nullptr);
119 LPOUTLINETEXTMETRIC otm = (LPOUTLINETEXTMETRIC)new BYTE[size];
120 GetOutlineTextMetrics(this->dc, size, otm);
121
122 /* Font height is minimum height plus the difference between the default
123 * height for this font size and the small size. */
124 int diff = scaled_height - ScaleGUITrad(FontCache::GetDefaultFontHeight(FontSize::Small));
125 /* Clamp() is not used as scaled_height could be greater than MAX_FONT_SIZE, which is not permitted in Clamp(). */
126 pixels = std::min(std::max(std::min<int>(otm->otmusMinimumPPEM, MAX_FONT_MIN_REC_SIZE) + diff, scaled_height), MAX_FONT_SIZE);
127
128 delete[] (BYTE*)otm;
129 SelectObject(dc, old);
130 DeleteObject(temp);
131 }
132 } else {
133 pixels = ScaleGUITrad(pixels);
134 }
135 this->used_size = pixels;
136
137 /* Create GDI font handle. */
138 this->logfont.lfHeight = -pixels;
139 this->logfont.lfWidth = 0;
140 this->logfont.lfOutPrecision = OUT_TT_ONLY_PRECIS;
141 this->logfont.lfQuality = ANTIALIASED_QUALITY;
142
143 if (this->font != nullptr) {
144 SelectObject(dc, this->old_font);
145 DeleteObject(this->font);
146 }
147 this->font = CreateFontIndirect(&this->logfont);
148 this->old_font = SelectObject(this->dc, this->font);
149
150 /* Query the font metrics we needed. */
151 UINT otmSize = GetOutlineTextMetrics(this->dc, 0, nullptr);
152 POUTLINETEXTMETRIC otm = (POUTLINETEXTMETRIC)new BYTE[otmSize];
153 GetOutlineTextMetrics(this->dc, otmSize, otm);
154
155 this->ascender = otm->otmTextMetrics.tmAscent;
156 this->descender = otm->otmTextMetrics.tmDescent;
157 this->height = this->ascender + this->descender;
158 this->glyph_size.cx = otm->otmTextMetrics.tmMaxCharWidth;
159 this->glyph_size.cy = otm->otmTextMetrics.tmHeight;
160
161 this->fontname = FS2OTTD((LPWSTR)((BYTE *)otm + (ptrdiff_t)otm->otmpFaceName));
162
163 Debug(Facility::Fontcache, Severity::Warning, "Loaded font '{}' with size {}", this->fontname, pixels);
164 delete[] (BYTE*)otm;
165}
166
171{
172 /* GUI scaling might have changed, determine font size anew if it was automatically selected. */
173 if (this->font != nullptr) this->SetFontSize(this->req_size);
174
176}
177
178/* virtual */ const Sprite *Win32FontCache::InternalGetGlyph(GlyphID key, bool aa)
179{
180 GLYPHMETRICS gm;
181 MAT2 mat = { {0, 1}, {0, 0}, {0, 0}, {0, 1} };
182
183 /* Call GetGlyphOutline with zero size initially to get required memory size. */
184 DWORD size = GetGlyphOutline(this->dc, key, GGO_GLYPH_INDEX | (aa ? GGO_GRAY8_BITMAP : GGO_BITMAP), &gm, 0, nullptr, &mat);
185 if (size == GDI_ERROR) UserError("Unable to render font glyph");
186
187 /* Add 1 scaled pixel for the shadow on the medium font. Our sprite must be at least 1x1 pixel. */
188 uint shadow = (this->fs == FontSize::Normal) ? ScaleGUITrad(1) : 0;
189 uint width = std::max(1U, (uint)gm.gmBlackBoxX + shadow);
190 uint height = std::max(1U, (uint)gm.gmBlackBoxY + shadow);
191
192 /* Limit glyph size to prevent overflows later on. */
193 if (width > MAX_GLYPH_DIM || height > MAX_GLYPH_DIM) UserError("Font glyph is too large");
194
195 /* Call GetGlyphOutline again with size to actually render the glyph. */
196 uint8_t *bmp = this->render_buffer.Allocate(size);
197 GetGlyphOutline(this->dc, key, GGO_GLYPH_INDEX | (aa ? GGO_GRAY8_BITMAP : GGO_BITMAP), &gm, size, bmp, &mat);
198
199 /* GDI has rendered the glyph, now we allocate a sprite and copy the image into it. */
200 SpriteLoader::SpriteCollection spritecollection;
201 SpriteLoader::Sprite &sprite = spritecollection[ZoomLevel::Min];
202 sprite.AllocateData(ZoomLevel::Min, width * height);
204 if (aa) sprite.colours.Set(SpriteComponent::Alpha);
205 sprite.width = width;
206 sprite.height = height;
207 sprite.x_offs = gm.gmptGlyphOrigin.x;
208 sprite.y_offs = this->ascender - gm.gmptGlyphOrigin.y;
209
210 if (size > 0) {
211 /* All pixel data returned by GDI is in the form of DWORD-aligned rows.
212 * For a non anti-aliased glyph, the returned bitmap has one bit per pixel.
213 * For anti-aliased rendering, GDI uses the strange value range of 0 to 64,
214 * inclusively. To map this to 0 to 255, we shift left by two and then
215 * subtract one. */
216 uint pitch = Align(aa ? gm.gmBlackBoxX : std::max((gm.gmBlackBoxX + 7u) / 8u, 1u), 4);
217
218 /* Draw shadow for medium size. */
219 if (this->fs == FontSize::Normal && !aa) {
220 for (uint y = 0; y < gm.gmBlackBoxY; y++) {
221 for (uint x = 0; x < gm.gmBlackBoxX; x++) {
222 if (aa ? (bmp[x + y * pitch] > 0) : HasBit(bmp[(x / 8) + y * pitch], 7 - (x % 8))) {
223 sprite.data[shadow + x + (shadow + y) * sprite.width].m = SHADOW_COLOUR;
224 sprite.data[shadow + x + (shadow + y) * sprite.width].a = aa ? (bmp[x + y * pitch] << 2) - 1 : 0xFF;
225 }
226 }
227 }
228 }
229
230 for (uint y = 0; y < gm.gmBlackBoxY; y++) {
231 for (uint x = 0; x < gm.gmBlackBoxX; x++) {
232 if (aa ? (bmp[x + y * pitch] > 0) : HasBit(bmp[(x / 8) + y * pitch], 7 - (x % 8))) {
233 sprite.data[x + y * sprite.width].m = FACE_COLOUR;
234 sprite.data[x + y * sprite.width].a = aa ? (bmp[x + y * pitch] << 2) - 1 : 0xFF;
235 }
236 }
237 }
238 }
239
240 UniquePtrSpriteAllocator allocator;
241 BlitterFactory::GetCurrentBlitter()->Encode(SpriteType::Font, spritecollection, allocator);
242
243 GlyphEntry new_glyph;
244 new_glyph.data = std::move(allocator.data);
245 new_glyph.width = gm.gmCellIncX;
246
247 return this->SetGlyphPtr(key, std::move(new_glyph)).GetSprite();
248}
249
250/* virtual */ GlyphID Win32FontCache::MapCharToGlyph(char32_t key, bool allow_fallback)
251{
252 assert(IsPrintable(key));
253
254 /* Convert characters outside of the BMP into surrogate pairs. */
255 WCHAR chars[2];
256 if (key >= 0x010000U) {
257 chars[0] = (wchar_t)(((key - 0x010000U) >> 10) + 0xD800);
258 chars[1] = (wchar_t)(((key - 0x010000U) & 0x3FF) + 0xDC00);
259 } else {
260 chars[0] = (wchar_t)(key & 0xFFFF);
261 }
262
263 WORD glyphs[2] = { 0, 0 };
264 GetGlyphIndicesW(this->dc, chars, key >= 0x010000U ? 2 : 1, glyphs, GGI_MARK_NONEXISTING_GLYPHS);
265
266 if (glyphs[0] != 0xFFFF) return glyphs[0];
267 return allow_fallback && key >= SCC_SPRITE_START && key <= SCC_SPRITE_END ? this->parent->MapCharToGlyph(key) : 0;
268}
269
270class Win32FontCacheFactory : FontCacheFactory {
271public:
272 Win32FontCacheFactory() : FontCacheFactory("win32", "Win32 font loader") {}
273
274 std::unique_ptr<FontCache> LoadFont(FontSize fs, FontType fonttype, bool search, const std::string &font_name, const std::any &os_handle) const override
275 {
276 if (fonttype != FontType::TrueType) return nullptr;
277
278 LOGFONT logfont{};
279 logfont.lfPitchAndFamily = fs == FontSize::Monospace ? FIXED_PITCH : VARIABLE_PITCH;
280 logfont.lfCharSet = DEFAULT_CHARSET;
281 logfont.lfOutPrecision = OUT_OUTLINE_PRECIS;
282 logfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
283
284 /* If a GDI font description is present, e.g. from the automatic font
285 * fallback search, use it. Otherwise, try to resolve it by font name. */
286 if (auto ptr = std::any_cast<LOGFONT>(&os_handle)) {
287 logfont = *ptr;
288 } else if (font_name.find('.') != std::string::npos) {
289 /* Might be a font file name, try load it. */
290 if (!TryLoadFontFromFile(font_name, logfont)) {
291 ShowInfo("Unable to load file '{}' for {} font, using default windows font selection instead", font_name, FontSizeToName(fs));
292 if (!search) return nullptr;
293 }
294 }
295
296 if (logfont.lfFaceName[0] == 0) {
297 logfont.lfWeight = StrContainsIgnoreCase(font_name, " bold") ? FW_BOLD : FW_NORMAL; // Poor man's way to allow selecting bold fonts.
298 convert_to_fs(font_name, logfont.lfFaceName);
299 }
300
301 return LoadWin32Font(fs, logfont, GetFontCacheFontSize(fs), font_name);
302 }
303
304 bool FindFallbackFont(const std::string &language_isocode, MissingGlyphSearcher *callback) const override
305 {
306 Debug(Facility::Fontcache, Severity::Error, "Trying fallback fonts");
307 EFCParam langInfo;
308 std::wstring lang = OTTD2FS(language_isocode);
309 if (GetLocaleInfoEx(lang.c_str(), LOCALE_FONTSIGNATURE, reinterpret_cast<LPWSTR>(&langInfo.locale), sizeof(langInfo.locale) / sizeof(wchar_t)) == 0) {
310 /* Invalid isocode or some other mysterious error, can't determine fallback font. */
311 Debug(Facility::Fontcache, Severity::Error, "Can't get locale info for fallback font (isocode={})", language_isocode);
312 return false;
313 }
314 langInfo.callback = callback;
315
316 LOGFONT font;
317 /* Enumerate all fonts. */
318 font.lfCharSet = DEFAULT_CHARSET;
319 font.lfFaceName[0] = '\0';
320 font.lfPitchAndFamily = 0;
321
322 HDC dc = GetDC(nullptr);
323 int ret = EnumFontFamiliesEx(dc, &font, (FONTENUMPROC)&EnumFontCallback, (LPARAM)&langInfo, 0);
324 ReleaseDC(nullptr, dc);
325 return ret == 0;
326 }
327
328private:
329 static std::unique_ptr<FontCache> LoadWin32Font(FontSize fs, const LOGFONT &logfont, uint size, std::string_view font_name)
330 {
331 HFONT font = CreateFontIndirect(&logfont);
332 if (font == nullptr) {
333 ShowInfo("Unable to use '{}' for {} font, Win32 reported error 0x{:X}, using sprite font instead", font_name, FontSizeToName(fs), GetLastError());
334 return nullptr;
335 }
336 DeleteObject(font);
337
338 return std::make_unique<Win32FontCache>(fs, logfont, size);
339 }
340
347 static bool TryLoadFontFromFile(const std::string &font_name, LOGFONT &logfont)
348 {
349 wchar_t fontPath[MAX_PATH] = {};
350
351 /* See if this is an absolute path. */
352 if (FileExists(font_name)) {
353 convert_to_fs(font_name, fontPath);
354 } else {
355 /* Scan the search-paths to see if it can be found. */
356 std::string full_font = FioFindFullPath(Subdirectory::Base, font_name);
357 if (!full_font.empty()) {
358 convert_to_fs(font_name, fontPath);
359 }
360 }
361
362 if (fontPath[0] != 0) {
363 if (AddFontResourceEx(fontPath, FR_PRIVATE, 0) != 0) {
364 /* Try a nice little undocumented function first for getting the internal font name.
365 * Some documentation is found at: http://www.undocprint.org/winspool/getfontresourceinfo */
366 static LibraryLoader _gdi32("gdi32.dll");
367 typedef BOOL(WINAPI *PFNGETFONTRESOURCEINFO)(LPCTSTR, LPDWORD, LPVOID, DWORD);
368 static PFNGETFONTRESOURCEINFO GetFontResourceInfo = _gdi32.GetFunction("GetFontResourceInfoW");
369
370 if (GetFontResourceInfo != nullptr) {
371 /* Try to query an array of LOGFONTs that describe the file. */
372 DWORD len = 0;
373 if (GetFontResourceInfo(fontPath, &len, nullptr, 2) && len >= sizeof(LOGFONT)) {
374 LOGFONT *buf = (LOGFONT *)new uint8_t[len];
375 if (GetFontResourceInfo(fontPath, &len, buf, 2)) {
376 logfont = *buf; // Just use first entry.
377 }
378 delete[](uint8_t *)buf;
379 }
380 }
381
382 /* No dice yet. Use the file name as the font face name, hoping it matches. */
383 if (logfont.lfFaceName[0] == 0) {
384 wchar_t fname[_MAX_FNAME];
385 _wsplitpath(fontPath, nullptr, nullptr, fname, nullptr);
386
387 wcsncpy_s(logfont.lfFaceName, lengthof(logfont.lfFaceName), fname, _TRUNCATE);
388 logfont.lfWeight = StrContainsIgnoreCase(font_name, " bold") || StrContainsIgnoreCase(font_name, "-bold") ? FW_BOLD : FW_NORMAL; // Poor man's way to allow selecting bold fonts.
389 }
390 }
391 }
392
393 return logfont.lfFaceName[0] != 0;
394 }
395
396private:
397 static Win32FontCacheFactory instance;
398};
399
400/* static */ Win32FontCacheFactory Win32FontCacheFactory::instance;
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr Timpl & Set()
Set all bits.
static Blitter * GetCurrentBlitter()
Get the current active blitter (always set by calling SelectBlitter).
Definition factory.hpp:139
int height
The height of the font.
Definition fontcache.h:28
std::unique_ptr< FontCache > parent
The parent of this font cache.
Definition fontcache.h:26
static void AddFallback(FontSizes fontsizes, std::string_view name, const std::any &os_handle={})
Add a fallback font, with optional OS-specific handle.
const FontSize fs
The size of the font.
Definition fontcache.h:27
int descender
The descender value of the font.
Definition fontcache.h:30
static bool TryFallback(FontSizes fontsizes, const std::set< char32_t > &glyphs, const std::string &name, const std::any &os_handle={})
Test a fallback font, with optional OS-specific handle, for specific glyphs.
int ascender
The ascender value of the font.
Definition fontcache.h:29
Function GetFunction(const std::string &symbol_name)
Get a function from a loaded library.
A searcher for missing glyphs.
FontSizes missing_fontsizes
Font sizes to actually search for.
std::set< char32_t > required_glyphs
Glyphs that are required.
virtual Sprite * Encode(SpriteType sprite_type, const SpriteLoader::SpriteCollection &sprite, SpriteAllocator &allocator)=0
Convert a sprite from the loader to our own format.
SpriteCollMap< Sprite > SpriteCollection
Type defining a collection of sprites, one for each zoom level.
static constexpr int MAX_GLYPH_DIM
Maximum glyph dimensions.
int used_size
Used font size.
int req_size
Requested font size.
void ClearFontCache() override
Reset cached glyphs.
static constexpr uint MAX_FONT_MIN_REC_SIZE
Upper limit for the recommended font size in case a font file contains nonsensical values.
TrueTypeFontCache(FontSize fs, int pixels)
Create a new TrueTypeFontCache.
SpriteAllocator that allocates memory via a unique_ptr array.
Definition spritecache.h:20
bool FindFallbackFont(const std::string &language_isocode, MissingGlyphSearcher *callback) const override
We would like to have a fallback font as the current one doesn't contain all characters we need.
std::unique_ptr< FontCache > LoadFont(FontSize fs, FontType fonttype, bool search, const std::string &font_name, const std::any &os_handle) const override
Try loading a font with this factory.
static bool TryLoadFontFromFile(const std::string &font_name, LOGFONT &logfont)
Try to load a font by filename.
HGDIOBJ old_font
Old font selected into the GDI context.
Definition font_win32.h:25
std::string fontname
Cached copy of loaded font facename.
Definition font_win32.h:27
HFONT font
The font face associated with this font.
Definition font_win32.h:23
GlyphID MapCharToGlyph(char32_t key, bool allow_fallback=true) override
Map a character into a glyph.
HDC dc
Cached GDI device context.
Definition font_win32.h:24
void ClearFontCache() override
Reset cached glyphs.
const Sprite * InternalGetGlyph(GlyphID key, bool aa) override
Load the glyph as a sprite.
~Win32FontCache() override
Release all the operating system objects.
LOGFONT logfont
Logical font information for selecting the font face.
Definition font_win32.h:22
SIZE glyph_size
Maximum size of regular glyphs.
Definition font_win32.h:26
Win32FontCache(FontSize fs, const LOGFONT &logfont, int pixels)
Create a new Win32FontCache.
ReusableBuffer< uint8_t > render_buffer
Temporary buffer for rendering glyphs.
Definition font_win32.h:29
Control codes that are embedded in the translation strings.
Functions related to debugging.
#define Debug(facility, severity, format_string,...)
Output a line of debugging information.
Definition debug.h:36
@ Fontcache
Fontcache message facility.
Definition debug_type.h:37
@ Warning
Warning, wrong but okay if you don't know.
Definition debug_type.h:17
@ Error
Error, but we are recovering.
Definition debug_type.h:16
Error reporting related functions.
Factory to 'query' all available blitters.
bool FileExists(std::string_view filename)
Test whether the given filename exists.
Definition fileio.cpp:133
std::string FioFindFullPath(Subdirectory subdir, std::string_view filename)
Find a path to the filename in one of the search directories.
Definition fileio.cpp:145
Functions for standard in/out file operations.
@ Base
Base directory for all subdirectories.
Definition fileio_type.h:88
Functions related to font handling on Win32.
uint GetFontCacheFontSize(FontSize fs)
Get the scalable font size to use for a FontSize.
Functions to read fonts from files and cache them.
FontType
Different types of font that can be loaded.
Definition fontcache.h:231
@ TrueType
Scalable TrueType fonts.
Definition fontcache.h:233
@ Font
A sprite used for fonts.
Definition gfx_type.h:407
FontSize
Available font sizes.
Definition gfx_type.h:248
@ Small
Index of the small font in the font tables.
Definition gfx_type.h:250
@ Normal
Index of the normal font in the font tables.
Definition gfx_type.h:249
@ Monospace
Index of the monospaced font in the font tables.
Definition gfx_type.h:252
Functions/types related to loading libraries dynamically.
Integer math functions.
constexpr T Align(const T x, uint n)
Return the smallest multiple of n equal or greater than x.
Definition math_func.hpp:37
A number of safeguards to prevent using unsafe methods.
Functions to cache sprites in memory.
@ Palette
Sprite has palette data.
@ Alpha
Sprite has alpha.
Definition of base types and functions in a cross-platform compatible way.
#define lengthof(array)
Return the length of an fixed size array.
Definition stdafx.h:261
bool StrContainsIgnoreCase(std::string_view str, std::string_view value)
Checks if a string is contained in another string, while ignoring the case of the characters.
Definition string.cpp:337
Functions related to low-level strings.
Functions related to OTTD's strings.
uint8_t m
Remap-channel.
uint8_t a
Alpha-channel.
Structure for passing information from the sprite loader to the blitter.
SpriteComponents colours
The colour components of the sprite with useful information.
void AllocateData(ZoomLevel zoom, size_t size)
Allocate the sprite data of this sprite.
uint16_t width
Width of the sprite.
int16_t x_offs
The x-offset of where the sprite will be drawn.
SpriteLoader::CommonPixel * data
The sprite itself.
uint16_t height
Height of the sprite.
int16_t y_offs
The y-offset of where the sprite will be drawn.
Data structure describing a sprite.
Container for information about a glyph.
std::unique_ptr< std::byte[]> data
The loaded sprite.
uint8_t width
The width of the glyph.
Common base definition for font file based font caches.
static const int MAX_FONT_SIZE
Maximum font size.
static RectPadding ScaleGUITrad(const RectPadding &r)
Scale a RectPadding to GUI zoom level.
Definition widget.cpp:49
std::string_view convert_from_fs(const std::wstring_view src, std::span< char > dst_buf)
Convert to OpenTTD's encoding from that of the environment in UNICODE.
Definition win32.cpp:407
std::wstring OTTD2FS(std::string_view name)
Convert from OpenTTD's encoding to a wide string.
Definition win32.cpp:389
std::string FS2OTTD(std::wstring_view name)
Convert to OpenTTD's encoding from a wide string.
Definition win32.cpp:373
wchar_t * convert_to_fs(std::string_view src, std::span< wchar_t > dst_buf)
Convert from OpenTTD's encoding to that of the environment in UNICODE.
Definition win32.cpp:424
Declarations of functions for MS windows systems.
Functions related to zooming.
@ Min
Minimum zoom level.
Definition zoom_type.h:23