From e729d381646dc79f4476e05028630e00aaf2bbad Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 17 Apr 2014 16:07:01 -0700 Subject: [PATCH] Add a warning for faux bold/italic to the fonts collector --- src/font_file_lister.cpp | 5 +++++ src/font_file_lister.h | 2 ++ src/font_file_lister_fontconfig.cpp | 8 ++++++++ 3 files changed, 15 insertions(+) diff --git a/src/font_file_lister.cpp b/src/font_file_lister.cpp index 2f9094933..4a93da7d0 100644 --- a/src/font_file_lister.cpp +++ b/src/font_file_lister.cpp @@ -142,6 +142,11 @@ void FontCollector::ProcessChunk(std::pair const& style) { status_callback(wxString::Format(_("Found '%s' at '%s'\n"), to_wx(style.first.facename), elem.make_preferred().wstring()), 0); } + if (res.fake_bold) + status_callback(wxString::Format(_("'%s' does not have a bold variant.\n"), to_wx(style.first.facename)), 3); + if (res.fake_italic) + status_callback(wxString::Format(_("'%s' does not have an italic variant.\n"), to_wx(style.first.facename)), 3); + if (res.missing.size()) { if (res.missing.size() > 50) status_callback(wxString::Format(_("'%s' is missing %d glyphs used.\n"), to_wx(style.first.facename), (int)res.missing.size()), 2); diff --git a/src/font_file_lister.h b/src/font_file_lister.h index 9448b7a35..4d70ef624 100644 --- a/src/font_file_lister.h +++ b/src/font_file_lister.h @@ -46,6 +46,8 @@ public: wxString missing; /// Paths to the file(s) containing the requested font std::vector paths; + bool fake_bold = false; + bool fake_italic = false; }; /// @brief Get the path to the font with the given styles diff --git a/src/font_file_lister_fontconfig.cpp b/src/font_file_lister_fontconfig.cpp index e2dbd0c07..3e26268f7 100644 --- a/src/font_file_lister_fontconfig.cpp +++ b/src/font_file_lister_fontconfig.cpp @@ -133,6 +133,14 @@ FontFileLister::CollectionResult FontConfigFontFileLister::GetFontPaths(std::str } } + int actual_weight = weight; + if (FcPatternGetInteger(match, FC_WEIGHT, 0, &actual_weight) == FcResultMatch) + ret.fake_bold = actual_weight < weight; + + int actual_slant = slant; + if (FcPatternGetInteger(match, FC_SLANT, 0, &actual_slant) == FcResultMatch) + ret.fake_italic = italic && !actual_slant; + ret.paths.emplace_back((const char *)file); return ret; }