register ArdourMono font with windows
This commit is contained in:
parent
ad7d3658d3
commit
242892999f
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user