summaryrefslogtreecommitdiff
path: root/src/fontcache.cpp
diff options
context:
space:
mode:
authorMichael Lutz <michi@icosahedron.de>2021-01-02 23:28:45 +0100
committerMichael Lutz <michi@icosahedron.de>2021-01-03 01:00:28 +0100
commit8c24b2b6ce7a2049d13132b2657ac3fce6145076 (patch)
tree81e7bd1a3c3a70d0910c8f3ea3096ccd3c7ace7a /src/fontcache.cpp
parent4bd3d18f34962436d8fea6843690cc142e5dd8c6 (diff)
downloadopenttd-8c24b2b6ce7a2049d13132b2657ac3fce6145076.tar.xz
Fix: [OSX] Fonts loaded directly from a file have to be registered with CoreText for proper text layout.
Diffstat (limited to 'src/fontcache.cpp')
-rw-r--r--src/fontcache.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/fontcache.cpp b/src/fontcache.cpp
index c523cade7..4a34a48d4 100644
--- a/src/fontcache.cpp
+++ b/src/fontcache.cpp
@@ -565,11 +565,19 @@ static void LoadFreeTypeFont(FontSize fs)
/* If font is an absolute path to a ttf, try loading that first. */
FT_Error error = FT_New_Face(_library, settings->font, 0, &face);
+#if defined(WITH_COCOA)
+ extern void MacOSRegisterExternalFont(const char *file_path);
+ if (error == FT_Err_Ok) MacOSRegisterExternalFont(settings->font);
+#endif
+
if (error != FT_Err_Ok) {
/* Check if font is a relative filename in one of our search-paths. */
std::string full_font = FioFindFullPath(BASE_DIR, settings->font);
if (!full_font.empty()) {
error = FT_New_Face(_library, full_font.c_str(), 0, &face);
+#if defined(WITH_COCOA)
+ if (error == FT_Err_Ok) MacOSRegisterExternalFont(full_font.c_str());
+#endif
}
}