summaryrefslogtreecommitdiff
path: root/gtk2_ardour/bundle_env_mingw.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-10-02 06:11:15 +0200
committerRobin Gareus <robin@gareus.org>2014-10-02 06:11:15 +0200
commit242892999f2d73e8a11e63bdc43f8fa50d760aa5 (patch)
tree95df68bd8dab28fc5025f26e27bfd9a915afbe4b /gtk2_ardour/bundle_env_mingw.cc
parentad7d3658d332ee705e079b06b9df7457698c9cd6 (diff)
register ArdourMono font with windows
Diffstat (limited to 'gtk2_ardour/bundle_env_mingw.cc')
-rw-r--r--gtk2_ardour/bundle_env_mingw.cc29
1 files changed, 28 insertions, 1 deletions
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 <stdlib.h>
#include "bundle_env.h"
#include "i18n.h"
+#include <glibmm.h>
#include <fontconfig/fontconfig.h>
+#include <windows.h>
+#include <wingdi.h>
#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<const FcChar8*>(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);
+ }
}