473 string query_desc(input_query_desc);
474 #if (PANGO_VERSION <= 12005) 476 query_desc.erase(std::remove(query_desc.begin(), query_desc.end(),
','),
478 const string kMediumStr =
" Medium";
479 std::size_t found = query_desc.find(kMediumStr);
480 if (found != std::string::npos) {
481 query_desc.erase(found, kMediumStr.length());
484 PangoFontDescription *desc = pango_font_description_from_string(
486 PangoFont* selected_font = NULL;
489 PangoFontMap* font_map = pango_cairo_font_map_get_default();
490 PangoContext* context = pango_context_new();
491 pango_context_set_font_map(context, font_map);
494 selected_font = pango_font_map_load_font(font_map, context, desc);
496 g_object_unref(context);
498 if (selected_font == NULL) {
499 pango_font_description_free(desc);
502 PangoFontDescription* selected_desc = pango_font_describe(selected_font);
504 bool equal = pango_font_description_equal(desc, selected_desc);
505 tlog(3,
"query weight = %d \t selected weight =%d\n",
506 pango_font_description_get_weight(desc),
507 pango_font_description_get_weight(selected_desc));
509 char* selected_desc_str = pango_font_description_to_string(selected_desc);
510 tlog(2,
"query_desc: '%s' Selected: '%s'\n", query_desc.c_str(),
512 if (!equal && best_match != NULL) {
513 *best_match = selected_desc_str;
516 int len = best_match->size();
517 if (len > 2 && best_match->at(len - 1) ==
'0' &&
518 best_match->at(len - 2) ==
' ') {
519 *best_match = best_match->substr(0, len - 2);
522 g_free(selected_desc_str);
523 pango_font_description_free(selected_desc);
524 g_object_unref(selected_font);
525 pango_font_description_free(desc);
static void SoftInitFontConfig()
#define DISABLE_HEAP_LEAK_CHECK