diff options
author | Robin Gareus <robin@gareus.org> | 2019-12-04 19:01:44 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-12-04 19:01:44 +0100 |
commit | a46bbabdaf98d98539da78851e3e820d81a65b87 (patch) | |
tree | 60aed9f4dcd71a97998c8a4b8ba8fbc6f0b6fd55 /gtk2_ardour/bundle_env_cocoa.cc | |
parent | 72bfc67027f952b9e084390cc3f8577933d9dab3 (diff) |
Load and register ArdourSans font at application start
Diffstat (limited to 'gtk2_ardour/bundle_env_cocoa.cc')
-rw-r--r-- | gtk2_ardour/bundle_env_cocoa.cc | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/gtk2_ardour/bundle_env_cocoa.cc b/gtk2_ardour/bundle_env_cocoa.cc index a9524e5abd..f8b84091ed 100644 --- a/gtk2_ardour/bundle_env_cocoa.cc +++ b/gtk2_ardour/bundle_env_cocoa.cc @@ -157,22 +157,38 @@ void load_custom_fonts() */ #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 - std::string ardour_mono_file; + std::string font_file; - if (!find_file (ardour_data_search_path(), "ArdourMono.ttf", ardour_mono_file)) { + if (!find_file (ardour_data_search_path(), "ArdourMono.ttf", font_file)) { cerr << _("Cannot find ArdourMono TrueType font") << endl; + } else { + CFStringRef ttf; + CFURLRef fontURL; + CFErrorRef error; + ttf = CFStringCreateWithBytes( + kCFAllocatorDefault, (UInt8*) font_file.c_str(), + font_file.length(), + kCFStringEncodingUTF8, FALSE); + fontURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, ttf, kCFURLPOSIXPathStyle, TRUE); + if (CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, &error) != true) { + cerr << _("Cannot load ArdourMono TrueType font.") << endl; + } } - CFStringRef ttf; - CFURLRef fontURL; - CFErrorRef error; - ttf = CFStringCreateWithBytes( - kCFAllocatorDefault, (UInt8*) ardour_mono_file.c_str(), - ardour_mono_file.length(), - kCFStringEncodingUTF8, FALSE); - fontURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, ttf, kCFURLPOSIXPathStyle, TRUE); - if (CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, &error) != true) { - cerr << _("Cannot load ArdourMono TrueType font.") << endl; + if (!find_file (ardour_data_search_path(), "ArdourSans.ttf", font_file)) { + cerr << _("Cannot find ArdourSans TrueType font") << endl; + } else { + CFStringRef ttf; + CFURLRef fontURL; + CFErrorRef error; + ttf = CFStringCreateWithBytes( + kCFAllocatorDefault, (UInt8*) font_file.c_str(), + font_file.length(), + kCFStringEncodingUTF8, FALSE); + fontURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, ttf, kCFURLPOSIXPathStyle, TRUE); + if (CTFontManagerRegisterFontsForURL(fontURL, kCTFontManagerScopeProcess, &error) != true) { + cerr << _("Cannot load ArdourSerif TrueType font.") << endl; + } } #endif } |