test for synthesized font faces.

This commit is contained in:
zdenop 2019-10-19 15:05:28 +02:00
parent f9d1bda7e3
commit 4a5ec186f6

View File

@ -485,6 +485,10 @@ std::vector<std::string> FontUtils::available_fonts_; // cache list
// Until then, we are restricted to using a hack where we try to load the font
// from the font_map, and then check what we loaded to see if it has the
// description we expected. If it is not, then the font is deemed unavailable.
//
// TODO: This function reports also some not synthesized fonts as not available
// e.g. 'Bitstream Charter Medium Italic', 'LMRoman17', so we need this hack
// until other solution is found.
/* static */
bool FontUtils::IsAvailableFont(const char* input_query_desc,
std::string* best_match) {
@ -505,6 +509,7 @@ bool FontUtils::IsAvailableFont(const char* input_query_desc,
}
if (selected_font == nullptr) {
pango_font_description_free(desc);
tlog(4, "** Font '%s' failed to load from font map!\n", input_query_desc);
return false;
}
PangoFontDescription* selected_desc = pango_font_describe(selected_font);
@ -531,6 +536,9 @@ bool FontUtils::IsAvailableFont(const char* input_query_desc,
pango_font_description_free(selected_desc);
g_object_unref(selected_font);
pango_font_description_free(desc);
if (!equal)
tlog(4, "** Font '%s' failed pango_font_description_equal!\n",
input_query_desc);
return equal;
}
@ -581,7 +589,9 @@ const std::vector<std::string>& FontUtils::ListAvailableFonts() {
for (int j = 0; j < n_faces; ++j) {
PangoFontDescription* desc = pango_font_face_describe(faces[j]);
char* desc_str = pango_font_description_to_string(desc);
if (IsAvailableFont(desc_str)) {
// "synthesized" font faces that are not truly loadable, so we skip it
if (!pango_font_face_is_synthesized(faces[j])
&& IsAvailableFont(desc_str)) {
available_fonts_.push_back(desc_str);
}
pango_font_description_free(desc);