diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-08-28 13:34:48 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-08-28 13:34:48 +0000 |
commit | eb973b9bdfd11467f63f1626f16d5d4005eb82a7 (patch) | |
tree | c19e9caf133b53f97ad8f155129eaef068009b19 /pango/pangofc-fontmap.c | |
parent | a3517dcc6de9bae1193075b7112aa7db97b39dcc (diff) | |
parent | da5b42263675acc7e615b8893a3a716646e910db (diff) | |
download | pango-eb973b9bdfd11467f63f1626f16d5d4005eb82a7.tar.gz |
Merge branch 'strdup-avoidance' into 'main'
fc: Avoid extra copies of family names
See merge request GNOME/pango!636
Diffstat (limited to 'pango/pangofc-fontmap.c')
-rw-r--r-- | pango/pangofc-fontmap.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index e21032f3..51f71cb1 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -2774,6 +2774,14 @@ pango_fc_convert_width_to_pango (int fc_stretch) PangoFontDescription * pango_fc_font_description_from_pattern (FcPattern *pattern, gboolean include_size) { + return font_description_from_pattern (pattern, include_size, FALSE); +} + +PangoFontDescription * +font_description_from_pattern (FcPattern *pattern, + gboolean include_size, + gboolean shallow) +{ PangoFontDescription *desc; PangoStyle style; PangoWeight weight; @@ -2782,8 +2790,7 @@ pango_fc_font_description_from_pattern (FcPattern *pattern, gboolean include_siz PangoGravity gravity; PangoVariant variant; gboolean all_caps; - - FcChar8 *s; + const char *s; int i; double d; FcResult res; @@ -2793,7 +2800,10 @@ pango_fc_font_description_from_pattern (FcPattern *pattern, gboolean include_siz res = FcPatternGetString (pattern, FC_FAMILY, 0, (FcChar8 **) &s); g_assert (res == FcResultMatch); - pango_font_description_set_family (desc, (gchar *)s); + if (shallow) + pango_font_description_set_family_static (desc, s); + else + pango_font_description_set_family (desc, s); if (FcPatternGetInteger (pattern, FC_SLANT, 0, &i) == FcResultMatch) style = pango_fc_convert_slant_to_pango (i); @@ -2821,8 +2831,6 @@ pango_fc_font_description_from_pattern (FcPattern *pattern, gboolean include_siz for (int i = 0; i < 32; i++) { - const char *s; - if (FcPatternGetString (pattern, FC_FONT_FEATURES, i, (FcChar8 **)&s) == FcResultMatch) { if (strcmp (s, "smcp=1") == 0) @@ -2907,7 +2915,12 @@ pango_fc_font_description_from_pattern (FcPattern *pattern, gboolean include_siz if (include_size && FcPatternGetString (pattern, FC_FONT_VARIATIONS, 0, (FcChar8 **)&s) == FcResultMatch) { if (s && *s) - pango_font_description_set_variations (desc, (char *)s); + { + if (shallow) + pango_font_description_set_variations_static (desc, s); + else + pango_font_description_set_variations (desc, s); + } } return desc; |