summaryrefslogtreecommitdiff
path: root/gtk2_ardour/bundle_env_mingw.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-12-04 19:01:44 +0100
committerRobin Gareus <robin@gareus.org>2019-12-04 19:01:44 +0100
commita46bbabdaf98d98539da78851e3e820d81a65b87 (patch)
tree60aed9f4dcd71a97998c8a4b8ba8fbc6f0b6fd55 /gtk2_ardour/bundle_env_mingw.cc
parent72bfc67027f952b9e084390cc3f8577933d9dab3 (diff)
Load and register ArdourSans font at application start
Diffstat (limited to 'gtk2_ardour/bundle_env_mingw.cc')
-rw-r--r--gtk2_ardour/bundle_env_mingw.cc33
1 files changed, 23 insertions, 10 deletions
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<const FcChar8*>(ardour_mono_file.c_str()));
- if (ret == FcFalse) {
+ if (!ardour_mono_file.empty () && FcFalse == FcConfigAppFontAddFile(config, reinterpret_cast<const FcChar8*>(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<const FcChar8*>(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);
}
}