summaryrefslogtreecommitdiff
path: root/src/fontdetection.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2013-08-05 20:36:03 +0000
committermichi_cc <michi_cc@openttd.org>2013-08-05 20:36:03 +0000
commit313cdb579ea3271a7d32f9413b83807df68f0971 (patch)
tree4e72bdf0422f5c61567b2f0607231dd2e0eee0f1 /src/fontdetection.cpp
parentd5681d7f6da296aaf33621db2285fee7869849d9 (diff)
downloadopenttd-313cdb579ea3271a7d32f9413b83807df68f0971.tar.xz
(svn r25662) -Fix: [OSX] Better rejection of unsuitable fonts during fallback auto-detection.
Diffstat (limited to 'src/fontdetection.cpp')
-rw-r--r--src/fontdetection.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/fontdetection.cpp b/src/fontdetection.cpp
index 943254ab3..51add9418 100644
--- a/src/fontdetection.cpp
+++ b/src/fontdetection.cpp
@@ -486,16 +486,26 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
for (CFIndex i = 0; descs != NULL && i < CFArrayGetCount(descs); i++) {
CTFontDescriptorRef font = (CTFontDescriptorRef)CFArrayGetValueAtIndex(descs, i);
+ /* Get font traits. */
+ CFDictionaryRef traits = (CFDictionaryRef)CTFontDescriptorCopyAttribute(font, kCTFontTraitsAttribute);
+ CTFontSymbolicTraits symbolic_traits;
+ CFNumberGetValue((CFNumberRef)CFDictionaryGetValue(traits, kCTFontSymbolicTrait), kCFNumberIntType, &symbolic_traits);
+ CFRelease(traits);
+
+ /* Skip symbol fonts and vertical fonts. */
+ if ((symbolic_traits & kCTFontClassMaskTrait) == (CTFontStylisticClass)kCTFontSymbolicClass || (symbolic_traits & kCTFontVerticalTrait)) continue;
+ /* Skip bold fonts (especially Arial Bold, which looks worse than regular Arial). */
+ if (symbolic_traits & kCTFontBoldTrait) continue;
+
/* Get font name. */
char name[128];
CFStringRef font_name = (CFStringRef)CTFontDescriptorCopyAttribute(font, kCTFontDisplayNameAttribute);
CFStringGetCString(font_name, name, lengthof(name), kCFStringEncodingUTF8);
CFRelease(font_name);
- /* Skip some inappropriate or ugly looking fonts that have better alternatives. */
- if (strncmp(name, "Courier", 7) == 0 || strncmp(name, "Apple Symbols", 13) == 0 ||
- strncmp(name, ".Aqua", 5) == 0 || strncmp(name, "LastResort", 10) == 0 ||
- strncmp(name, "GB18030 Bitmap", 14) == 0) continue;
+ /* There are some special fonts starting with an '.' and the last
+ * resort font that aren't usable. Skip them. */
+ if (name[0] == '.' || strncmp(name, "LastResort", 10) == 0) continue;
/* Save result. */
callback->SetFontNames(settings, name);
@@ -526,9 +536,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
if (strstr(name, "Italic") != NULL || strstr(name, "Bold")) continue;
/* Skip some inappropriate or ugly looking fonts that have better alternatives. */
- if (strncmp(name, "Courier", 7) == 0 || strncmp(name, "Apple Symbols", 13) == 0 ||
- strncmp(name, ".Aqua", 5) == 0 || strncmp(name, "LastResort", 10) == 0 ||
- strncmp(name, "GB18030 Bitmap", 14) == 0) continue;
+ if (name[0] == '.' || strncmp(name, "Apple Symbols", 13) == 0 || strncmp(name, "LastResort", 10) == 0) continue;
/* Save result. */
callback->SetFontNames(settings, name);