summaryrefslogtreecommitdiff
path: root/pango/pangofc-font.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-08-27 20:39:14 -0400
committerMatthias Clasen <mclasen@redhat.com>2022-08-27 20:39:14 -0400
commit94b7c4ae13e3b71ffc283db1989389f22bd66446 (patch)
tree43ccbd82c43dd2537cd927d9b154ddceb053c6e1 /pango/pangofc-font.c
parenta3517dcc6de9bae1193075b7112aa7db97b39dcc (diff)
downloadpango-94b7c4ae13e3b71ffc283db1989389f22bd66446.tar.gz
fc: Avoid extra copies of family names
When we create a PangoFcFont from an FcPattern, we know that the pattern will live as long as the font and the font description we create at the same time. So there is no need to copy the strings we get out of the pattern.
Diffstat (limited to 'pango/pangofc-font.c')
-rw-r--r--pango/pangofc-font.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index 9d555a37..02fb67fc 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -24,6 +24,7 @@
#include "pango-font-private.h"
#include "pangofc-font-private.h"
#include "pangofc-fontmap.h"
+#include "pangofc-fontmap-private.h"
#include "pangofc-private.h"
#include "pango-layout.h"
#include "pango-impl-utils.h"
@@ -172,8 +173,8 @@ pango_fc_font_finalize (GObject *object)
g_object_unref (fontmap);
}
- FcPatternDestroy (fcfont->font_pattern);
pango_font_description_free (fcfont->description);
+ FcPatternDestroy (fcfont->font_pattern);
if (priv->decoder)
_pango_fc_font_set_decoder (fcfont, NULL);
@@ -209,9 +210,9 @@ pattern_is_transformed (FcPattern *pattern)
static void
pango_fc_font_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
PangoFcFont *fcfont = PANGO_FC_FONT (object);
@@ -219,25 +220,25 @@ pango_fc_font_set_property (GObject *object,
{
case PROP_PATTERN:
{
- FcPattern *pattern = g_value_get_pointer (value);
+ FcPattern *pattern = g_value_get_pointer (value);
- g_return_if_fail (pattern != NULL);
- g_return_if_fail (fcfont->font_pattern == NULL);
+ g_return_if_fail (pattern != NULL);
+ g_return_if_fail (fcfont->font_pattern == NULL);
- FcPatternReference (pattern);
- fcfont->font_pattern = pattern;
- fcfont->description = pango_fc_font_description_from_pattern (pattern, TRUE);
- fcfont->is_hinted = pattern_is_hinted (pattern);
- fcfont->is_transformed = pattern_is_transformed (pattern);
+ FcPatternReference (pattern);
+ fcfont->font_pattern = pattern;
+ fcfont->description = font_description_from_pattern (pattern, TRUE, TRUE);
+ fcfont->is_hinted = pattern_is_hinted (pattern);
+ fcfont->is_transformed = pattern_is_transformed (pattern);
}
goto set_decoder;
case PROP_FONTMAP:
{
- PangoFcFontMap *fcfontmap = PANGO_FC_FONT_MAP (g_value_get_object (value));
+ PangoFcFontMap *fcfontmap = PANGO_FC_FONT_MAP (g_value_get_object (value));
- g_return_if_fail (fcfont->fontmap == NULL);
- g_weak_ref_set ((GWeakRef *) &fcfont->fontmap, fcfontmap);
+ g_return_if_fail (fcfont->fontmap == NULL);
+ g_weak_ref_set ((GWeakRef *) &fcfont->fontmap, fcfontmap);
}
goto set_decoder;