From 242892999f2d73e8a11e63bdc43f8fa50d760aa5 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 2 Oct 2014 06:11:15 +0200 Subject: [PATCH] register ArdourMono font with windows --- gtk2_ardour/bundle_env_mingw.cc | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/bundle_env_mingw.cc b/gtk2_ardour/bundle_env_mingw.cc index 41a6aab5cc..723e3cee0c 100644 --- a/gtk2_ardour/bundle_env_mingw.cc +++ b/gtk2_ardour/bundle_env_mingw.cc @@ -17,10 +17,14 @@ */ +#include #include "bundle_env.h" #include "i18n.h" +#include #include +#include +#include #include "ardour/ardour.h" #include "ardour/search_paths.h" @@ -33,11 +37,25 @@ using namespace std; using namespace PBD; using namespace ARDOUR; - void fixup_bundle_environment (int, char* [], const char** localedir) { + EnvironmentalProtectionAgency::set_global_epa (new EnvironmentalProtectionAgency (true)); /* what to do ? */ + // we should at least set ARDOUR_DATA_PATH to prevent the warning message. + // setting a FONTCONFIG_FILE won't hurt either see bundle_env_msvc.cc + // (pangocairo prefers the windows gdi backend unless PANGOCAIRO_BACKEND=fc is set) + + // Unset GTK_RC_FILES so that only ardour specific files are loaded + Glib::unsetenv ("GTK_RC_FILES"); +} + +static __cdecl void unload_custom_fonts() { + std::string ardour_mono_file; + if (!find_file (ardour_data_search_path(), "ArdourMono.ttf", ardour_mono_file)) { + return; + } + RemoveFontResource(ardour_mono_file.c_str()); } void load_custom_fonts() @@ -46,8 +64,10 @@ void load_custom_fonts() if (!find_file (ardour_data_search_path(), "ArdourMono.ttf", ardour_mono_file)) { cerr << _("Cannot find ArdourMono TrueType font") << endl; + return; } + // pango with fontconfig backend FcConfig *config = FcInitLoadConfigAndFonts(); FcBool ret = FcConfigAppFontAddFile(config, reinterpret_cast(ardour_mono_file.c_str())); @@ -60,4 +80,11 @@ void load_custom_fonts() if (ret == FcFalse) { cerr << _("Failed to set fontconfig configuration.") << endl; } + + // 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); + } } -- 2.30.2