[pango/wip-bitmatrix: 170/173] Do coverage trimming incrementally
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/wip-bitmatrix: 170/173] Do coverage trimming incrementally
- Date: Mon, 22 Feb 2021 13:35:34 +0000 (UTC)
commit 4875b69b25bd389501fa8726c9723be85c56c3de
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Aug 22 11:13:35 2020 -0400
Do coverage trimming incrementally
Some tradeoffs here.
FcFontSetSort returns faster (5.4ms vs 6.75ms),
but we have much bigger fontset (~ 4k fonts vs ~200),
and we have to keep extra data around (the charset, and
the skip table).
pango/pangofc-fontmap.c | 45 ++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 42 insertions(+), 3 deletions(-)
---
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index aa90345e..d859c493 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -766,6 +766,12 @@ struct _PangoFcPatterns {
FcPattern *pattern;
FcPattern *match;
FcFontSet *fontset;
+
+ char *skip; /* 0: undetermined, 1: skip: 2: include */
+
+ FcCharSet *cs; /* merged charset of the coverage of the
+ * non-undetermined fonts.
+ */
};
static FcFontSet *
@@ -860,7 +866,7 @@ sort_in_thread (GTask *task,
fontset = FcFontSetSort (td->config,
&td->fonts, 1,
td->pattern,
- FcTrue,
+ FcFalse,
NULL,
&result);
@@ -948,6 +954,9 @@ pango_fc_patterns_unref (PangoFcPatterns *pats)
if (pats->fontset)
FcFontSetDestroy (pats->fontset);
+ g_clear_pointer (&pats->skip, g_free);
+ g_clear_pointer (&pats->cs, FcCharSetDestroy);
+
g_cond_clear (&pats->cond);
g_mutex_clear (&pats->mutex);
@@ -1066,10 +1075,40 @@ pango_fc_patterns_get_font_pattern (PangoFcPatterns *pats, int i, gboolean *prep
if (fontset)
{
- if (i < fontset->nfont)
+ int f, k;
+
+ /* Find the i'th fontset skipping the ones that are
+ * not adding coverage.
+ */
+
+ if (!pats->skip)
+ {
+ pats->skip = g_new0 (char, fontset->nfont);
+ pats->cs = FcCharSetCreate ();
+ }
+
+ for (f = 0, k = 0; f < fontset->nfont && k < i; f++)
+ {
+ if (pats->skip[f] == 0) /* calculate whether to skip */
+ {
+ FcCharSet *fcs;
+ FcBool added = FcFalse;
+
+ FcPatternGetCharSet (fontset->fonts[f], "charset", 0, &fcs);
+
+ FcCharSetMerge (pats->cs, fcs, &added);
+
+ pats->skip[f] = added ? 2 : 1;
+ }
+
+ if (pats->skip[f] == 2) /* don't skip */
+ k++;
+ }
+
+ if (f < fontset->nfont)
{
*prepare = TRUE;
- return fontset->fonts[i];
+ return fontset->fonts[f];
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]