499 string query_desc(input_query_desc);
500 if (PANGO_VERSION <= 12005) {
502 query_desc.erase(std::remove(query_desc.begin(), query_desc.end(),
','),
504 const string kMediumStr =
" Medium";
505 std::size_t found = query_desc.find(kMediumStr);
506 if (found != std::string::npos) {
507 query_desc.erase(found, kMediumStr.length());
511 PangoFontDescription *desc = pango_font_description_from_string(
513 PangoFont* selected_font =
NULL;
516 PangoFontMap* font_map = pango_cairo_font_map_get_default();
517 PangoContext* context = pango_context_new();
518 pango_context_set_font_map(context, font_map);
521 selected_font = pango_font_map_load_font(font_map, context, desc);
523 g_object_unref(context);
525 if (selected_font ==
NULL) {
526 pango_font_description_free(desc);
529 PangoFontDescription* selected_desc = pango_font_describe(selected_font);
531 bool equal = pango_font_description_equal(desc, selected_desc);
532 tlog(3,
"query weight = %d \t selected weight =%d\n",
533 pango_font_description_get_weight(desc),
534 pango_font_description_get_weight(selected_desc));
536 char* selected_desc_str = pango_font_description_to_string(selected_desc);
537 tlog(2,
"query_desc: '%s' Selected: 's'\n", query_desc.c_str(),
539 if (!equal && best_match !=
NULL) {
540 *best_match = selected_desc_str;
543 int len = best_match->size();
544 if (len > 2 && best_match->at(len - 1) ==
'0' &&
545 best_match->at(len - 2) ==
' ') {
546 *best_match = best_match->substr(0, len - 2);
549 g_free(selected_desc_str);
550 pango_font_description_free(selected_desc);
551 g_object_unref(selected_font);
552 pango_font_description_free(desc);
#define DISABLE_HEAP_LEAK_CHECK
static void InitFontConfig(bool force_clear, const string &fonts_dir)