[pango/pango2: 160/201] hbfontmap: Don't return duplicate fonts
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2: 160/201] hbfontmap: Don't return duplicate fonts
- Date: Sat, 11 Jun 2022 02:22:33 +0000 (UTC)
commit 2601a108e57e20602e7fb72e7e4b9e560afa6ecf
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jun 5 01:36:26 2022 -0400
hbfontmap: Don't return duplicate fonts
For generic families, we want to avoid returning
a new copy of the same font for every char we
try. Otherwise, we end up with single-char runs,
since itemizations relies on comparing fonts by
pointer.
pango/pango-hbfontmap.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/pango/pango-hbfontmap.c b/pango/pango-hbfontmap.c
index 89f80a30..99b5ecdb 100644
--- a/pango/pango-hbfontmap.c
+++ b/pango/pango-hbfontmap.c
@@ -196,10 +196,24 @@ pango_fontset_cached_get_font (PangoFontset *fontset,
wc);
if (face)
{
- retval = pango_font_face_create_font (face,
- self->description,
- self->dpi,
- self->matrix);
+ GHashTableIter iter;
+ PangoFont *font;
+
+ g_hash_table_iter_init (&iter, self->cache);
+ while (g_hash_table_iter_next (&iter, NULL, (gpointer *)&font))
+ {
+ if (pango_font_get_face (font) == face)
+ {
+ retval = g_object_ref (font);
+ break;
+ }
+ }
+
+ if (!retval)
+ retval = pango_font_face_create_font (face,
+ self->description,
+ self->dpi,
+ self->matrix);
break;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]