[pango/win32-fixes] pangowin32-fontmap.c: Look harder for the matching font
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/win32-fixes] pangowin32-fontmap.c: Look harder for the matching font
- Date: Mon, 9 Aug 2021 08:38:21 +0000 (UTC)
commit a7c882df35d84b1def7322b8d4f837c9f6d24922
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Mon Aug 9 16:00:49 2021 +0800
pangowin32-fontmap.c: Look harder for the matching font
When we look up our font from the list of fonts that we enumerated from
the system, follow what the CoreText backend does, so that if the font
gravity in the font description is getting in our way to find the font,
look for it again without the gravity.
This will enable us to find the font that really exists but was not found
due to FontDescription attributes.
Partially fixes #583.
pango/pangowin32-fontmap.c | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c
index b6341f52..200ea9ce 100644
--- a/pango/pangowin32-fontmap.c
+++ b/pango/pangowin32-fontmap.c
@@ -1037,19 +1037,35 @@ pango_win32_font_map_load_font (PangoFontMap *fontmap,
win32family = g_hash_table_lookup (win32fontmap->families, families[i]);
if (win32family)
{
+ PangoFontDescription *new_desc;
+ PangoFontDescription *best_desc = NULL;
+
PING (("got win32family"));
tmp_list = win32family->faces;
+
while (tmp_list)
{
PangoWin32Face *face = tmp_list->data;
+ new_desc = pango_font_face_describe (PANGO_FONT_FACE (face));
+ pango_font_description_set_gravity (new_desc,
+ pango_font_description_get_gravity (description));
if (pango_font_description_better_match (description,
- best_match ? best_match->description : NULL,
- face->description))
- best_match = face;
+ best_desc,
+ new_desc))
+ {
+ pango_font_description_free (best_desc);
+ best_desc = new_desc;
+ best_match = face;
+ }
+ else
+ pango_font_description_free (new_desc);
tmp_list = tmp_list->next;
}
+
+ if (best_desc != NULL)
+ pango_font_description_free (best_desc);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]