summaryrefslogtreecommitdiff
path: root/pango/pangofc-font.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-07-09 23:09:02 -0400
committerMatthias Clasen <mclasen@redhat.com>2019-07-11 23:27:08 -0400
commitb0d40c174a1cdebb0ef3fd9b187b6aabf8fc0a20 (patch)
treed306e6aef29d49411e20399a31b377ad56990255 /pango/pangofc-font.c
parent9ca6fde86a534854b088f09effe02589fdb9a64b (diff)
downloadpango-b0d40c174a1cdebb0ef3fd9b187b6aabf8fc0a20.tar.gz
fc: Implement get_features for fc fonts
We take features out of the FcPattern and translate them into harfbuzz features.
Diffstat (limited to 'pango/pangofc-font.c')
-rw-r--r--pango/pangofc-font.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index 79fb07c1..fb51b3c6 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -89,7 +89,10 @@ static PangoFontMetrics * pango_fc_font_get_metrics (PangoFont *font,
static PangoFontMap * pango_fc_font_get_font_map (PangoFont *font);
static PangoFontDescription *pango_fc_font_describe (PangoFont *font);
static PangoFontDescription *pango_fc_font_describe_absolute (PangoFont *font);
-
+static void pango_fc_font_get_features (PangoFont *font,
+ hb_feature_t *features,
+ guint len,
+ guint *num_features);
#define PANGO_FC_FONT_LOCK_FACE(font) (PANGO_FC_FONT_GET_CLASS (font)->lock_face (font))
#define PANGO_FC_FONT_UNLOCK_FACE(font) (PANGO_FC_FONT_GET_CLASS (font)->unlock_face (font))
@@ -116,6 +119,7 @@ pango_fc_font_class_init (PangoFcFontClass *class)
font_class->get_coverage = pango_fc_font_get_coverage;
font_class->get_metrics = pango_fc_font_get_metrics;
font_class->get_font_map = pango_fc_font_get_font_map;
+ font_class->get_features = pango_fc_font_get_features;
g_object_class_install_property (object_class, PROP_PATTERN,
g_param_spec_pointer ("pattern",
@@ -1086,3 +1090,28 @@ pango_fc_font_get_raw_extents (PangoFcFont *fcfont,
PANGO_FC_FONT_UNLOCK_FACE (fcfont);
}
+static void
+pango_fc_font_get_features (PangoFont *font,
+ hb_feature_t *features,
+ guint len,
+ guint *num_features)
+{
+ /* Setup features from fontconfig pattern. */
+ PangoFcFont *fc_font = PANGO_FC_FONT (font);
+ if (fc_font->font_pattern)
+ {
+ char *s;
+ while (*num_features < len &&
+ FcResultMatch == FcPatternGetString (fc_font->font_pattern,
+ PANGO_FC_FONT_FEATURES,
+ *num_features,
+ (FcChar8 **) &s))
+ {
+ gboolean ret = hb_feature_from_string (s, -1, &features[*num_features]);
+ features[*num_features].start = 0;
+ features[*num_features].end = (unsigned int) -1;
+ if (ret)
+ (*num_features)++;
+ }
+ }
+}