Fix: [OSX] Fonts loaded directly from a file have to be registered with CoreText for proper text layout.

This commit is contained in:
Michael Lutz
2021-01-02 23:28:45 +01:00
parent 4bd3d18f34
commit 8c24b2b6ce
3 changed files with 21 additions and 0 deletions

View File

@@ -289,6 +289,17 @@ void MacOSResetScriptCache(FontSize size)
_font_cache[size].reset();
}
/** Register an external font file with the CoreText system. */
void MacOSRegisterExternalFont(const char *file_path)
{
if (!MacOSVersionIsAtLeast(10, 6, 0)) return;
CFAutoRelease<CFStringRef> path(CFStringCreateWithCString(kCFAllocatorDefault, file_path, kCFStringEncodingUTF8));
CFAutoRelease<CFURLRef> url(CFURLCreateWithFileSystemPath(kCFAllocatorDefault, path.get(), kCFURLPOSIXPathStyle, false));
CTFontManagerRegisterFontsForURL(url.get(), kCTFontManagerScopeProcess, nullptr);
}
/** Store current language locale as a CoreFounation locale. */
void MacOSSetCurrentLocaleName(const char *iso_code)
{