[pango/pango2: 187/195] hbfontmap: Don't return duplicate fonts
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2: 187/195] hbfontmap: Don't return duplicate fonts
- Date: Mon, 6 Jun 2022 04:14:47 +0000 (UTC)
commit 02a58a9b34808b9c0f1e568fa6cb2a2bdb3f0f4b
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]