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 } diff --git a/gtk2_ardour/bundle_env_linux.cc b/gtk2_ardour/bundle_env_linux.cc index 0e254a1ebf..387a9aaae8 100644 --- a/gtk2_ardour/bundle_env_linux.cc +++ b/gtk2_ardour/bundle_env_linux.cc @@ -122,22 +122,29 @@ fixup_bundle_environment (int /*argc*/, char* argv[], string & localedir) void load_custom_fonts() { - std::string ardour_mono_file; + FcConfig* config = FcInitLoadConfigAndFonts(); - if (!find_file (ardour_data_search_path(), "ArdourMono.ttf", ardour_mono_file)) { + std::string font_file; + + if (!find_file (ardour_data_search_path(), "ArdourMono.ttf", font_file)) { cerr << _("Cannot find ArdourMono TrueType font") << endl; + } else { + FcBool ret = FcConfigAppFontAddFile(config, reinterpret_cast(font_file.c_str())); + if (ret == FcFalse) { + cerr << _("Cannot load ArdourMono TrueType font.") << endl; + } } - FcConfig *config = FcInitLoadConfigAndFonts(); - FcBool ret = FcConfigAppFontAddFile(config, reinterpret_cast(ardour_mono_file.c_str())); - - if (ret == FcFalse) { - 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 { + FcBool ret = FcConfigAppFontAddFile(config, reinterpret_cast(font_file.c_str())); + if (ret == FcFalse) { + cerr << _("Cannot load ArdourSans TrueType font.") << endl; + } } - ret = FcConfigSetCurrent(config); - - if (ret == FcFalse) { + if (FcFalse == FcConfigSetCurrent(config)) { cerr << _("Failed to set fontconfig configuration.") << endl; } } diff --git a/gtk2_ardour/bundle_env_mingw.cc b/gtk2_ardour/bundle_env_mingw.cc index 5c6c73233b..e979b8ac82 100644 --- a/gtk2_ardour/bundle_env_mingw.cc +++ b/gtk2_ardour/bundle_env_mingw.cc @@ -94,42 +94,55 @@ fixup_bundle_environment (int, char* [], string & localedir) static __cdecl void unload_custom_fonts() { - std::string ardour_mono_file; - if (!find_file (ardour_data_search_path(), "ArdourMono.ttf", ardour_mono_file)) { - return; + std::string font_file; + if (find_file (ardour_data_search_path(), "ArdourMono.ttf", font_file)) { + RemoveFontResource(font_file.c_str()); + } + if (find_file (ardour_data_search_path(), "ArdourSerif.ttf", font_file)) { + RemoveFontResource(font_file.c_str()); } - RemoveFontResource(ardour_mono_file.c_str()); } void load_custom_fonts() { std::string ardour_mono_file; + std::string ardour_sans_file; if (!find_file (ardour_data_search_path(), "ArdourMono.ttf", ardour_mono_file)) { cerr << _("Cannot find ArdourMono TrueType font") << endl; + } + + if (!find_file (ardour_data_search_path(), "ArdourSans.ttf", ardour_sans_file)) { + cerr << _("Cannot find ArdourSans TrueType font") << endl; + } + + if (ardour_mono_file.empty () && ardour_sans_file.empty ()) { return; } if (pango_font_map_get_type() == PANGO_TYPE_FT2_FONT_MAP) { FcConfig *config = FcInitLoadConfigAndFonts(); - FcBool ret = FcConfigAppFontAddFile(config, reinterpret_cast(ardour_mono_file.c_str())); - if (ret == FcFalse) { + if (!ardour_mono_file.empty () && FcFalse == FcConfigAppFontAddFile(config, reinterpret_cast(ardour_mono_file.c_str()))) { cerr << _("Cannot load ArdourMono TrueType font.") << endl; } - ret = FcConfigSetCurrent(config); + if (!ardour_sans_file.empty () && FcFalse == FcConfigAppFontAddFile(config, reinterpret_cast(ardour_sans_file.c_str()))) { + cerr << _("Cannot load ArdourSans TrueType font.") << endl; + } - if (ret == FcFalse) { + if (FcFalse == FcConfigSetCurrent(config)) { cerr << _("Failed to set fontconfig configuration.") << endl; } } else { // pango with win32 backend if (0 == AddFontResource(ardour_mono_file.c_str())) { cerr << _("Cannot register ArdourMono TrueType font with windows gdi.") << endl; - } else { - atexit (&unload_custom_fonts); } + if (0 == AddFontResource(ardour_sans_file.c_str())) { + cerr << _("Cannot register ArdourSans TrueType font with windows gdi.") << endl; + } + atexit (&unload_custom_fonts); } } diff --git a/gtk2_ardour/bundle_env_msvc.cc b/gtk2_ardour/bundle_env_msvc.cc index 97d09c9779..f556526169 100644 --- a/gtk2_ardour/bundle_env_msvc.cc +++ b/gtk2_ardour/bundle_env_msvc.cc @@ -484,22 +484,29 @@ fixup_bundle_environment (int argc, char* argv[], string & localedir) void load_custom_fonts() { - std::string ardour_mono_file; + FcConfig* config = FcInitLoadConfigAndFonts(); - if (!find_file (ardour_data_search_path(), "ArdourMono.ttf", ardour_mono_file)) { + std::string font_file; + + if (!find_file (ardour_data_search_path(), "ArdourMono.ttf", font_file)) { cerr << _("Cannot find ArdourMono TrueType font") << endl; + } else { + FcBool ret = FcConfigAppFontAddFile(config, reinterpret_cast(font_file.c_str())); + if (ret == FcFalse) { + cerr << _("Cannot load ArdourMono TrueType font.") << endl; + } } - FcConfig *config = FcInitLoadConfigAndFonts(); - FcBool ret = FcConfigAppFontAddFile(config, reinterpret_cast(ardour_mono_file.c_str())); - - if (ret == FcFalse) { - 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 { + FcBool ret = FcConfigAppFontAddFile(config, reinterpret_cast(font_file.c_str())); + if (ret == FcFalse) { + cerr << _("Cannot load ArdourSans TrueType font.") << endl; + } } - ret = FcConfigSetCurrent(config); - - if (ret == FcFalse) { + if (FcFalse == FcConfigSetCurrent(config)) { cerr << _("Failed to set fontconfig configuration.") << endl; } } diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index ce53bbc85f..c63524d914 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -910,6 +910,7 @@ def build(bld): # Icons/Images bld.install_files(os.path.join (bld.env['DATADIR'], 'icons'), bld.path.ant_glob('icons/*.png')) bld.install_files(bld.env['DATADIR'], 'ArdourMono.ttf') + bld.install_files(bld.env['DATADIR'], 'ArdourSerif.ttf') # Application/Product specific resources (icon, splash) pgmname = bld.env['PROGRAM_NAME']