Actually load the fontconfig config file in the fonts collector on OS X

This commit is contained in:
Thomas Goyne 2012-10-09 07:44:27 -07:00
parent f7ff76a251
commit a56bf25d00
1 changed files with 19 additions and 1 deletions

View File

@ -30,8 +30,13 @@
#include "compat.h" #include "compat.h"
#include <libaegisub/log.h>
#include <libaegisub/util.h> #include <libaegisub/util.h>
#ifdef __APPLE__
#include <libaegisub/util_osx.h>
#endif
#ifndef AGI_PRE #ifndef AGI_PRE
#include <wx/intl.h> #include <wx/intl.h>
#endif #endif
@ -67,10 +72,23 @@ namespace {
agi::util::str_lower(b); agi::util::str_lower(b);
return a.compare(b); return a.compare(b);
} }
FcConfig *init_fontconfig() {
#ifdef __APPLE__
FcConfig *config = FcConfigCreate();
std::string conf_path = agi::util::OSX_GetBundleResourcesDirectory() + "/etc/fonts/fonts.conf";
if (FcConfigParseAndLoad(config, (unsigned char *)conf_path.c_str(), FcTrue))
return config;
LOG_E("font_collector/fontconfig") << "Loading fontconfig configuration file failed";
FcConfigDestroy(config);
#endif
return FcInitLoadConfig();
}
} }
FontConfigFontFileLister::FontConfigFontFileLister(FontCollectorStatusCallback cb) FontConfigFontFileLister::FontConfigFontFileLister(FontCollectorStatusCallback cb)
: config(FcInitLoadConfig(), FcConfigDestroy) : config(init_fontconfig(), FcConfigDestroy)
{ {
cb(_("Updating font cache\n"), 0); cb(_("Updating font cache\n"), 0);
FcConfigBuildFonts(config); FcConfigBuildFonts(config);