summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pango/pangofc-font.c31
-rw-r--r--pango/pangofc-fontmap-private.h3
-rw-r--r--pango/pangofc-fontmap.c25
3 files changed, 38 insertions, 21 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;
diff --git a/pango/pangofc-fontmap-private.h b/pango/pangofc-fontmap-private.h
index 68daea6c..42fa7e3d 100644
--- a/pango/pangofc-fontmap-private.h
+++ b/pango/pangofc-fontmap-private.h
@@ -191,6 +191,9 @@ struct _PangoFcFontMapClass
void (*_pango_reserved4) (void);
};
+PangoFontDescription *font_description_from_pattern (FcPattern *pattern,
+ gboolean include_size,
+ gboolean shallow);
G_END_DECLS
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;