OpenTTD Source 20261112-master-gbcbec5e63f
font_osx.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"
12#include "font_osx.h"
15#include "../../error_func.h"
16#include "../../fileio_func.h"
17#include "../../spritecache.h"
18#include "../../string_func.h"
19#include "../../strings_func.h"
20#include "../../zoom_func.h"
21#include "macos.h"
22
24
25#include "../../safeguards.h"
26
27CoreTextFontCache::CoreTextFontCache(FontSize fs, CFAutoRelease<CTFontDescriptorRef> &&font, int pixels) : TrueTypeFontCache(fs, pixels), font_desc(std::move(font))
28{
29 this->SetFontSize(pixels);
30}
31
36{
37 /* GUI scaling might have changed, determine font size anew if it was automatically selected. */
38 if (this->font) this->SetFontSize(this->req_size);
39
41}
42
43void CoreTextFontCache::SetFontSize(int pixels)
44{
45 if (pixels == 0) {
46 /* Try to determine a good height based on the height recommended by the font. */
47 int scaled_height = ScaleGUITrad(FontCache::GetDefaultFontHeight(this->fs));
48 pixels = scaled_height;
49
50 CFAutoRelease<CTFontRef> font(CTFontCreateWithFontDescriptor(this->font_desc.get(), 0.0f, nullptr));
51 if (font) {
52 float min_size = 0.0f;
53
54 /* The 'head' TrueType table contains information about the
55 * 'smallest readable size in pixels'. Try to read it, if
56 * that doesn't work, we use the default OS font size instead.
57 *
58 * Reference: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6head.html */
59 CFAutoRelease<CFDataRef> data(CTFontCopyTable(font.get(), kCTFontTableHead, kCTFontTableOptionNoOptions));
60 if (data) {
61 uint16_t lowestRecPPEM; // At offset 46 of the 'head' TrueType table.
62 CFDataGetBytes(data.get(), CFRangeMake(46, sizeof(lowestRecPPEM)), (UInt8 *)&lowestRecPPEM);
63 min_size = CFSwapInt16BigToHost(lowestRecPPEM); // TrueType data is always big-endian.
64 } else {
65 CFAutoRelease<CFNumberRef> size((CFNumberRef)CTFontCopyAttribute(font.get(), kCTFontSizeAttribute));
66 CFNumberGetValue(size.get(), kCFNumberFloatType, &min_size);
67 }
68
69 /* Font height is minimum height plus the difference between the default
70 * height for this font size and the small size. */
71 int diff = scaled_height - ScaleGUITrad(FontCache::GetDefaultFontHeight(FontSize::Small));
72 /* Clamp() is not used as scaled_height could be greater than MAX_FONT_SIZE, which is not permitted in Clamp(). */
73 pixels = std::min(std::max(std::min<int>(min_size, MAX_FONT_MIN_REC_SIZE) + diff, scaled_height), MAX_FONT_SIZE);
74 }
75 } else {
76 pixels = ScaleGUITrad(pixels);
77 }
78 this->used_size = pixels;
79
80 this->font.reset(CTFontCreateWithFontDescriptor(this->font_desc.get(), pixels, nullptr));
81
82 /* Query the font metrics we needed. We generally round all values up to
83 * make sure we don't inadvertently cut off a row or column of pixels,
84 * except when determining glyph to glyph advances. */
85 this->ascender = (int)std::ceil(CTFontGetAscent(this->font.get()));
86 this->descender = -(int)std::ceil(CTFontGetDescent(this->font.get()));
87 this->height = this->ascender - this->descender;
88
89 /* Get real font name. */
90 char name[128];
91 CFAutoRelease<CFStringRef> font_name((CFStringRef)CTFontCopyAttribute(this->font.get(), kCTFontDisplayNameAttribute));
92 CFStringGetCString(font_name.get(), name, lengthof(name), kCFStringEncodingUTF8);
93 this->font_name = name;
94
95 Debug(Facility::Fontcache, Severity::Warning, "Loaded font '{}' with size {}", this->font_name, pixels);
96}
97
98GlyphID CoreTextFontCache::MapCharToGlyph(char32_t key, bool allow_fallback)
99{
100 assert(IsPrintable(key));
101
102 /* Convert characters outside of the Basic Multilingual Plane into surrogate pairs. */
103 UniChar chars[2];
104 if (key >= 0x010000U) {
105 chars[0] = (UniChar)(((key - 0x010000U) >> 10) + 0xD800);
106 chars[1] = (UniChar)(((key - 0x010000U) & 0x3FF) + 0xDC00);
107 } else {
108 chars[0] = (UniChar)(key & 0xFFFF);
109 }
110
111 CGGlyph glyph[2] = {0, 0};
112 if (CTFontGetGlyphsForCharacters(this->font.get(), chars, glyph, key >= 0x010000U ? 2 : 1)) {
113 return glyph[0];
114 }
115
116 if (allow_fallback && key >= SCC_SPRITE_START && key <= SCC_SPRITE_END) {
117 return this->parent->MapCharToGlyph(key);
118 }
119
120 return 0;
121}
122
123const Sprite *CoreTextFontCache::InternalGetGlyph(GlyphID key, bool use_aa)
124{
125 /* Get glyph size. */
126 CGGlyph glyph = (CGGlyph)key;
127 CGRect bounds = CTFontGetOpticalBoundsForGlyphs(this->font.get(), &glyph, nullptr, 1, 0);
128 if (CGRectIsNull(bounds)) UserError("Unable to render font glyph");
129
130 uint bb_width = (uint)std::ceil(bounds.size.width) + 1; // Sometimes the glyph bounds are too tight and cut of the last pixel after rounding.
131 uint bb_height = (uint)std::ceil(bounds.size.height);
132
133 /* Add 1 scaled pixel for the shadow on the medium font. Our sprite must be at least 1x1 pixel. */
134 uint shadow = (this->fs == FontSize::Normal) ? ScaleGUITrad(1) : 0;
135 uint width = std::max(1U, bb_width + shadow);
136 uint height = std::max(1U, bb_height + shadow);
137
138 /* Limit glyph size to prevent overflows later on. */
139 if (width > MAX_GLYPH_DIM || height > MAX_GLYPH_DIM) UserError("Font glyph is too large");
140
141 SpriteLoader::SpriteCollection spritecollection;
142 SpriteLoader::Sprite &sprite = spritecollection[ZoomLevel::Min];
143 sprite.AllocateData(ZoomLevel::Min, width * height);
145 if (use_aa) sprite.colours.Set(SpriteComponent::Alpha);
146 sprite.width = width;
147 sprite.height = height;
148 sprite.x_offs = (int16_t)std::round(CGRectGetMinX(bounds));
149 sprite.y_offs = this->ascender - (int16_t)std::ceil(CGRectGetMaxY(bounds));
150
151 if (bounds.size.width > 0) {
152 /* Glyph is not a white-space glyph. Render it to a bitmap context. */
153
154 /* We only need the alpha channel, as we apply our own colour constants to the sprite. */
155 int pitch = Align(bb_width, 16);
156 CFAutoRelease<CGContextRef> context(CGBitmapContextCreate(nullptr, bb_width, bb_height, 8, pitch, nullptr, kCGImageAlphaOnly));
157 const uint8_t *bmp = static_cast<uint8_t *>(CGBitmapContextGetData(context.get()));
158 /* Set antialias according to requirements. */
159 CGContextSetAllowsAntialiasing(context.get(), use_aa);
160 CGContextSetAllowsFontSubpixelPositioning(context.get(), use_aa);
161 CGContextSetAllowsFontSubpixelQuantization(context.get(), !use_aa);
162 CGContextSetShouldSmoothFonts(context.get(), false);
163
164 CGPoint pos{-bounds.origin.x, -bounds.origin.y};
165 CTFontDrawGlyphs(this->font.get(), &glyph, &pos, 1, context.get());
166
167 /* Draw shadow for medium size. */
168 if (this->fs == FontSize::Normal && !use_aa) {
169 for (uint y = 0; y < bb_height; y++) {
170 for (uint x = 0; x < bb_width; x++) {
171 if (bmp[y * pitch + x] > 0) {
172 sprite.data[shadow + x + (shadow + y) * sprite.width].m = SHADOW_COLOUR;
173 sprite.data[shadow + x + (shadow + y) * sprite.width].a = use_aa ? bmp[x + y * pitch] : 0xFF;
174 }
175 }
176 }
177 }
178
179 /* Extract pixel data. */
180 for (uint y = 0; y < bb_height; y++) {
181 for (uint x = 0; x < bb_width; x++) {
182 if (bmp[y * pitch + x] > 0) {
183 sprite.data[x + y * sprite.width].m = FACE_COLOUR;
184 sprite.data[x + y * sprite.width].a = use_aa ? bmp[x + y * pitch] : 0xFF;
185 }
186 }
187 }
188 }
189
190 UniquePtrSpriteAllocator allocator;
191 BlitterFactory::GetCurrentBlitter()->Encode(SpriteType::Font, spritecollection, allocator);
192
193 GlyphEntry new_glyph;
194 new_glyph.data = std::move(allocator.data);
195 new_glyph.width = (uint8_t)std::round(CTFontGetAdvancesForGlyphs(this->font.get(), kCTFontOrientationDefault, &glyph, nullptr, 1));
196
197 return this->SetGlyphPtr(key, std::move(new_glyph)).GetSprite();
198}
199
200class CoreTextFontCacheFactory : public FontCacheFactory {
201public:
202 CoreTextFontCacheFactory() : FontCacheFactory("coretext", "CoreText font loader") {}
203
204 std::unique_ptr<FontCache> LoadFont(FontSize fs, FontType fonttype, bool search, const std::string &font_name, const std::any &) const override
205 {
206 if (fonttype != FontType::TrueType) return nullptr;
207
208 /* Might be a font file name, try load it. */
209 CFAutoRelease<CTFontDescriptorRef> font_ref(LoadFontFromFile(font_name));
210 if (!font_ref) ShowInfo("Unable to load file '{}' for {} font, using default OS font selection instead", font_name, FontSizeToName(fs));
211
212 if (!font_ref && search) {
213 CFAutoRelease<CFStringRef> name(CFStringCreateWithCString(kCFAllocatorDefault, font_name.c_str(), kCFStringEncodingUTF8));
214
215 /* Simply creating the font using CTFontCreateWithNameAndSize will *always* return
216 * something, no matter the name. As such, we can't use it to check for existence.
217 * We instead query the list of all font descriptors that match the given name which
218 * does not do this stupid name fallback. */
219 CFAutoRelease<CTFontDescriptorRef> name_desc(CTFontDescriptorCreateWithNameAndSize(name.get(), 0.0));
220 CFAutoRelease<CFSetRef> mandatory_attribs(CFSetCreate(kCFAllocatorDefault, const_cast<const void **>(reinterpret_cast<const void * const *>(&kCTFontNameAttribute)), 1, &kCFTypeSetCallBacks));
221 CFAutoRelease<CFArrayRef> descs(CTFontDescriptorCreateMatchingFontDescriptors(name_desc.get(), mandatory_attribs.get()));
222
223 /* Assume the first result is the one we want. */
224 if (descs && CFArrayGetCount(descs.get()) > 0) {
225 font_ref.reset((CTFontDescriptorRef)CFArrayGetValueAtIndex(descs.get(), 0));
226 CFRetain(font_ref.get());
227 }
228 }
229
230 if (!font_ref) {
231 ShowInfo("Unable to use '{}' for {} font, using sprite font instead", font_name, FontSizeToName(fs));
232 return nullptr;
233 }
234
235 return std::make_unique<CoreTextFontCache>(fs, std::move(font_ref), GetFontCacheFontSize(fs));
236 }
237
238 bool FindFallbackFont(const std::string &language_isocode, MissingGlyphSearcher *callback) const override
239 {
240 /* Determine fallback font using CoreText. This uses the language isocode
241 * to find a suitable font. CoreText is available from 10.5 onwards. */
242 std::string lang;
243 if (language_isocode == "zh-TW") {
244 /* Traditional Chinese */
245 lang = "zh-Hant";
246 } else if (language_isocode == "zh-CN") {
247 /* Simplified Chinese */
248 lang = "zh-Hans";
249 } else {
250 /* Just copy the isocode. */
251 lang = language_isocode;
252 }
253
254 /* Create a font descriptor matching the wanted language and latin (english) glyphs.
255 * Can't use CFAutoRelease here for everything due to the way the dictionary has to be created. */
256 CFStringRef lang_codes[2];
257 lang_codes[0] = CFStringCreateWithCString(kCFAllocatorDefault, lang.c_str(), kCFStringEncodingUTF8);
258 lang_codes[1] = CFSTR("en");
259 CFArrayRef lang_arr = CFArrayCreate(kCFAllocatorDefault, (const void **)lang_codes, lengthof(lang_codes), &kCFTypeArrayCallBacks);
260 CFAutoRelease<CFDictionaryRef> lang_attribs(CFDictionaryCreate(kCFAllocatorDefault, const_cast<const void **>(reinterpret_cast<const void *const *>(&kCTFontLanguagesAttribute)), (const void **)&lang_arr, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
261 CFAutoRelease<CTFontDescriptorRef> lang_desc(CTFontDescriptorCreateWithAttributes(lang_attribs.get()));
262 CFRelease(lang_arr);
263 CFRelease(lang_codes[0]);
264
265 /* Get array of all font descriptors for the wanted language. */
266 CFAutoRelease<CFSetRef> mandatory_attribs(CFSetCreate(kCFAllocatorDefault, const_cast<const void **>(reinterpret_cast<const void *const *>(&kCTFontLanguagesAttribute)), 1, &kCFTypeSetCallBacks));
267 CFAutoRelease<CFArrayRef> descs(CTFontDescriptorCreateMatchingFontDescriptors(lang_desc.get(), mandatory_attribs.get()));
268
269 bool result = false;
270 for (int tries = 0; tries < 2; tries++) {
271 for (CFIndex i = 0; descs.get() != nullptr && i < CFArrayGetCount(descs.get()); i++) {
272 CTFontDescriptorRef font = (CTFontDescriptorRef)CFArrayGetValueAtIndex(descs.get(), i);
273
274 /* Get font traits. */
275 CFAutoRelease<CFDictionaryRef> traits((CFDictionaryRef)CTFontDescriptorCopyAttribute(font, kCTFontTraitsAttribute));
276 CTFontSymbolicTraits symbolic_traits;
277 CFNumberGetValue((CFNumberRef)CFDictionaryGetValue(traits.get(), kCTFontSymbolicTrait), kCFNumberIntType, &symbolic_traits);
278
279 /* Skip symbol fonts and vertical fonts. */
280 if ((symbolic_traits & kCTFontClassMaskTrait) == (CTFontStylisticClass)kCTFontSymbolicClass || (symbolic_traits & kCTFontVerticalTrait)) continue;
281 /* Skip bold fonts (especially Arial Bold, which looks worse than regular Arial). */
282 if (symbolic_traits & kCTFontBoldTrait) continue;
283 /* Select monospaced fonts if asked for. */
284 if (((symbolic_traits & kCTFontMonoSpaceTrait) == kCTFontMonoSpaceTrait) != callback->missing_fontsizes.Test(FontSize::Monospace)) continue;
285
286 /* Get font name. */
287 char buffer[128];
288 CFAutoRelease<CFStringRef> font_name((CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontDisplayNameAttribute));
289 CFStringGetCString(font_name.get(), buffer, std::size(buffer), kCFStringEncodingUTF8);
290
291 /* Serif fonts usually look worse on-screen with only small
292 * font sizes. As such, we try for a sans-serif font first.
293 * If we can't find one in the first try, try all fonts. */
294 if (tries == 0 && (symbolic_traits & kCTFontClassMaskTrait) != (CTFontStylisticClass)kCTFontSansSerifClass) continue;
295
296 /* There are some special fonts starting with an '.' and the last
297 * resort font that aren't usable. Skip them. */
298 std::string_view name{buffer};
299 if (name.starts_with(".") || name.starts_with("LastResort")) continue;
300
301 /* Save result. */
302 result = FontCache::TryFallback(callback->missing_fontsizes, callback->required_glyphs, std::string{name});
303 if (result) {
305 Debug(Facility::Fontcache, Severity::Warning, "CT-Font for {}: {}", language_isocode, name);
306 break;
307 }
308 }
309 }
310
311 if (!result) {
312 /* For some OS versions, the font 'Arial Unicode MS' does not report all languages it
313 * supports. If we didn't find any other font, just try it, maybe we get lucky. */
314 result = FontCache::TryFallback(callback->missing_fontsizes, callback->required_glyphs, "Arial Unicode MS");
315 if (result) {
316 FontCache::AddFallback(callback->missing_fontsizes, "Arial Unicode MS");
317 }
318 }
319
320 return result;
321 }
322
323private:
324 static CTFontDescriptorRef LoadFontFromFile(const std::string &font_name)
325 {
326 /* Might be a font file name, try load it. Direct font loading is
327 * only supported starting on OSX 10.6. */
329
330 /* See if this is an absolute path. */
331 if (FileExists(font_name)) {
332 path.reset(CFStringCreateWithCString(kCFAllocatorDefault, font_name.c_str(), kCFStringEncodingUTF8));
333 } else {
334 /* Scan the search-paths to see if it can be found. */
335 std::string full_font = FioFindFullPath(Subdirectory::Base, font_name);
336 if (!full_font.empty()) {
337 path.reset(CFStringCreateWithCString(kCFAllocatorDefault, full_font.c_str(), kCFStringEncodingUTF8));
338 }
339 }
340
341 if (path) {
342 /* Try getting a font descriptor to see if the system can use it. */
343 CFAutoRelease<CFURLRef> url(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, path.get(), kCFURLPOSIXPathStyle, false));
344 CFAutoRelease<CFArrayRef> descs(CTFontManagerCreateFontDescriptorsFromURL(url.get()));
345
346 if (descs && CFArrayGetCount(descs.get()) > 0) {
347 CTFontDescriptorRef font_ref = (CTFontDescriptorRef)CFArrayGetValueAtIndex(descs.get(), 0);
348 CFRetain(font_ref);
349 return font_ref;
350 }
351 }
352
353 return nullptr;
354 }
355
356private:
357 static CoreTextFontCacheFactory instance;
358};
359
360/* static */ CoreTextFontCacheFactory CoreTextFontCacheFactory::instance;
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
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.
Definition font_osx.cpp:238
std::unique_ptr< FontCache > LoadFont(FontSize fs, FontType fonttype, bool search, const std::string &font_name, const std::any &) const override
Try loading a font with this factory.
Definition font_osx.cpp:204
CFAutoRelease< CTFontDescriptorRef > font_desc
Font descriptor excluding font size.
Definition font_osx.h:19
std::string font_name
Cached font name.
Definition font_osx.h:22
const Sprite * InternalGetGlyph(GlyphID key, bool use_aa) override
Load the glyph as a sprite.
Definition font_osx.cpp:123
CFAutoRelease< CTFontRef > font
CoreText font handle.
Definition font_osx.h:20
void ClearFontCache() override
Reset cached glyphs.
Definition font_osx.cpp:35
GlyphID MapCharToGlyph(char32_t key, bool allow_fallback=true) override
Map a character into a glyph.
Definition font_osx.cpp:98
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
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.
Font cache for fonts that are based on a TrueType font.
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.
SpriteAllocator that allocates memory via a unique_ptr array.
Definition spritecache.h:20
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 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 MacOS.
uint GetFontCacheFontSize(FontSize fs)
Get the scalable font size to use for a FontSize.
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 related to MacOS support.
std::unique_ptr< typename std::remove_pointer< T >::type, CFDeleter< typename std::remove_pointer< T >::type > > CFAutoRelease
Specialisation of std::unique_ptr for CoreFoundation objects.
Definition macos.h:34
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
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.
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
Functions related to zooming.
@ Min
Minimum zoom level.
Definition zoom_type.h:23