diff --git a/src/font_file_lister_fontconfig.cpp b/src/font_file_lister_fontconfig.cpp index 72e010da7..408d596ee 100644 --- a/src/font_file_lister_fontconfig.cpp +++ b/src/font_file_lister_fontconfig.cpp @@ -19,29 +19,12 @@ #include #include -#ifdef __APPLE__ -#include -#endif - #include #include #include #include namespace { -FcConfig *init_fontconfig() { -#ifdef __APPLE__ - FcConfig *config = FcConfigCreate(); - std::string conf_path = agi::util::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(); -} - bool pattern_matches(FcPattern *pat, const char *field, std::string const& name) { FcChar8 *str; for (int i = 0; FcPatternGetString(pat, field, i, &str) == FcResultMatch; ++i) { @@ -68,7 +51,7 @@ void find_font(FcFontSet *src, FcFontSet *dst, std::string const& family) { } FontConfigFontFileLister::FontConfigFontFileLister(FontCollectorStatusCallback &cb) -: config(init_fontconfig(), FcConfigDestroy) +: config(FcInitLoadConfig(), FcConfigDestroy) { cb(_("Updating font cache\n"), 0); FcConfigBuildFonts(config); @@ -114,38 +97,6 @@ CollectionResult FontConfigFontFileLister::GetFontPaths(std::string const& facen auto match = matches->fonts[0]; -#ifdef _WIN32 - wxMemoryDC dc; - // Use EnumFontFamiliesEx to verify the match, as fontconfig sometimes gives - // us some incorrect matches along with the correct one - for (FcPattern *pat : boost::make_iterator_range(&matches->fonts[0], &matches->fonts[matches->nfont])) { - FcChar8 *fullname; - if (FcPatternGetString(pat, FC_FULLNAME, 0, &fullname) != FcResultMatch) - continue; - - LOGFONT lf = {0}; - lf.lfCharSet = DEFAULT_CHARSET; - wcsncpy(lf.lfFaceName, agi::charset::ConvertW((const char *)fullname).c_str(), 31); - - auto cb = [&](const LOGFONT *lf) { - auto face = agi::charset::ConvertW(lf->lfFaceName); - boost::to_lower(face); - return face == family; - }; - - using type = decltype(cb); - bool found = !EnumFontFamiliesEx(dc.GetHDC(), &lf, - [](const LOGFONT *lf, const TEXTMETRIC *, DWORD, LPARAM lParam) -> int { - return !(*reinterpret_cast(lParam))(lf); - }, (LPARAM)&cb, 0); - - if (found) { - match = pat; - break; - } - } -#endif - FcChar8 *file; if(FcPatternGetString(match, FC_FILE, 0, &file) != FcResultMatch) return ret;