summaryrefslogtreecommitdiff
path: root/pango/pangofc-fontmap.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-08-15 15:49:58 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-08-15 15:49:58 -0400
commitc4ae4782053aa5e8d5b2e78b580bfd74aa9a038d (patch)
tree7db0a4b6bb59fd62bb3c4b00b34b0df22d742c9b /pango/pangofc-fontmap.c
parente9703ea37a471fb1f61f57e644c78a6a411ad5d6 (diff)
downloadpango-c4ae4782053aa5e8d5b2e78b580bfd74aa9a038d.tar.gz
Don't call FcFontSetSort twice
We can do the format filtering on the unsorted font lists. Sorting the same list twice may be fast, but there's still some setup overhead.
Diffstat (limited to 'pango/pangofc-fontmap.c')
-rw-r--r--pango/pangofc-fontmap.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 6d7ae3aa..4c2aa094 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -876,16 +876,21 @@ pango_fc_patterns_get_font_pattern (PangoFcPatterns *pats, int i, gboolean *prep
if (!pats->fontset)
{
FcResult result;
- FcFontSet *fontset;
- FcFontSet *filtered;
+ FcFontSet *filtered[2] = { NULL, };
+ int i, n = 0;
- fontset = FcFontSort (pats->fontmap->priv->config, pats->pattern, FcFalse, NULL, &result);
- filtered = filter_fontset_by_format (fontset);
- FcFontSetDestroy (fontset);
+ for (i = 0; i < 2; i++)
+ {
+ FcFontSet *fonts = FcConfigGetFonts (pats->fontmap->priv->config, i);
+ if (fonts)
+ filtered[n++] = filter_fontset_by_format (fonts);
+ }
+
+ pats->fontset = FcFontSetSort (pats->fontmap->priv->config, filtered, n, pats->pattern, FcTrue, NULL, &result);
- pats->fontset = FcFontSetSort (pats->fontmap->priv->config, &filtered, 1, pats->pattern, FcTrue, NULL, &result);
+ for (i = 0; i < n; i++)
+ FcFontSetDestroy (filtered[i]);
- FcFontSetDestroy (filtered);
if (pats->match)
{