mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-12 09:09:09 +00:00
Change: [OSX] When auto-detecting a font, try for sans-serif first.
On a display, especially with small fonts or low pixel sizes, sans-serif fonts are usually easier to read than serif fonts.
This commit is contained in:
@@ -101,6 +101,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
|||||||
CFAutoRelease<CFArrayRef> descs(CTFontDescriptorCreateMatchingFontDescriptors(lang_desc.get(), mandatory_attribs.get()));
|
CFAutoRelease<CFArrayRef> descs(CTFontDescriptorCreateMatchingFontDescriptors(lang_desc.get(), mandatory_attribs.get()));
|
||||||
|
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
for (int tries = 0; tries < 2; tries++) {
|
||||||
for (CFIndex i = 0; descs.get() != nullptr && i < CFArrayGetCount(descs.get()); i++) {
|
for (CFIndex i = 0; descs.get() != nullptr && i < CFArrayGetCount(descs.get()); i++) {
|
||||||
CTFontDescriptorRef font = (CTFontDescriptorRef)CFArrayGetValueAtIndex(descs.get(), i);
|
CTFontDescriptorRef font = (CTFontDescriptorRef)CFArrayGetValueAtIndex(descs.get(), i);
|
||||||
|
|
||||||
@@ -121,6 +122,11 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
|||||||
CFAutoRelease<CFStringRef> font_name((CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontDisplayNameAttribute));
|
CFAutoRelease<CFStringRef> font_name((CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontDisplayNameAttribute));
|
||||||
CFStringGetCString(font_name.get(), name, lengthof(name), kCFStringEncodingUTF8);
|
CFStringGetCString(font_name.get(), name, lengthof(name), kCFStringEncodingUTF8);
|
||||||
|
|
||||||
|
/* Serif fonts usually look worse on-screen with only small
|
||||||
|
* font sizes. As such, we try for a sans-serif font first.
|
||||||
|
* If we can't find one in the first try, try all fonts. */
|
||||||
|
if (tries == 0 && (symbolic_traits & kCTFontClassMaskTrait) != (CTFontStylisticClass)kCTFontSansSerifClass) continue;
|
||||||
|
|
||||||
/* There are some special fonts starting with an '.' and the last
|
/* There are some special fonts starting with an '.' and the last
|
||||||
* resort font that aren't usable. Skip them. */
|
* resort font that aren't usable. Skip them. */
|
||||||
if (name[0] == '.' || strncmp(name, "LastResort", 10) == 0) continue;
|
if (name[0] == '.' || strncmp(name, "LastResort", 10) == 0) continue;
|
||||||
@@ -133,6 +139,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
/* For some OS versions, the font 'Arial Unicode MS' does not report all languages it
|
/* For some OS versions, the font 'Arial Unicode MS' does not report all languages it
|
||||||
|
Reference in New Issue
Block a user