diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-07-12 03:35:16 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-07-12 03:35:16 +0000 |
commit | 00233bd8b863a87cbf59344b1aed1feba04c66ca (patch) | |
tree | 4f388b57fbd10a79785bf3d829419492d51fd77b /pango/pangofc-font.c | |
parent | 5590411f895d9e9bc9edd983c9c8df845ec13018 (diff) | |
parent | ec4864eef5f5c067093ac46dd66cc948de3467dc (diff) | |
download | pango-00233bd8b863a87cbf59344b1aed1feba04c66ca.tar.gz |
Merge branch 'font-features-getter' into 'master'
Font features getter
See merge request GNOME/pango!82
Diffstat (limited to 'pango/pangofc-font.c')
-rw-r--r-- | pango/pangofc-font.c | 31 |
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)++; + } + } +} |