diff --git a/aegisub/src/font_file_lister_fontconfig.cpp b/aegisub/src/font_file_lister_fontconfig.cpp index 4a99389a0..ee490c786 100644 --- a/aegisub/src/font_file_lister_fontconfig.cpp +++ b/aegisub/src/font_file_lister_fontconfig.cpp @@ -30,8 +30,13 @@ #include "compat.h" +#include #include +#ifdef __APPLE__ +#include +#endif + #ifndef AGI_PRE #include #endif @@ -67,10 +72,23 @@ namespace { agi::util::str_lower(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) -: config(FcInitLoadConfig(), FcConfigDestroy) +: config(init_fontconfig(), FcConfigDestroy) { cb(_("Updating font cache\n"), 0); FcConfigBuildFonts(config);