summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/pango-sections.txt1
-rw-r--r--modules/basic/basic-fc.c24
-rw-r--r--pango/pangofc-fontmap.h14
3 files changed, 38 insertions, 1 deletions
diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt
index 5adfa937..02eba9dd 100644
--- a/docs/pango-sections.txt
+++ b/docs/pango-sections.txt
@@ -915,6 +915,7 @@ pango_fc_font_map_find_decoder
pango_fc_font_map_cache_clear
pango_fc_font_map_shutdown
pango_fc_font_description_from_pattern
+PANGO_FC_FONT_FEATURES
PANGO_FC_GRAVITY
PANGO_FC_VERSION
PANGO_FC_PRGNAME
diff --git a/modules/basic/basic-fc.c b/modules/basic/basic-fc.c
index 548cee6a..1ceaeabe 100644
--- a/modules/basic/basic-fc.c
+++ b/modules/basic/basic-fc.c
@@ -29,6 +29,7 @@
#include "pango-engine.h"
#include "pango-utils.h"
+#include "pangofc-fontmap.h"
#include "pangofc-font.h"
#include <hb-ft.h>
#include <hb-glib.h>
@@ -318,6 +319,8 @@ basic_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED,
int last_cluster;
guint i, num_glyphs;
unsigned int item_offset = item_text - paragraph_text;
+ hb_feature_t features[8];
+ unsigned int num_features = 0;
g_return_if_fail (font != NULL);
g_return_if_fail (analysis != NULL);
@@ -367,7 +370,26 @@ basic_engine_shape (PangoEngineShape *engine G_GNUC_UNUSED,
(item_offset + item_length == paragraph_length ? HB_BUFFER_FLAG_EOT : 0));
hb_buffer_add_utf8 (hb_buffer, paragraph_text, paragraph_length, item_offset, item_length);
- hb_shape (hb_font, hb_buffer, NULL, 0);
+
+ /* Setup features from fontconfig pattern. */
+ if (fc_font->font_pattern)
+ {
+ char *s;
+ while (num_features < G_N_ELEMENTS (features) &&
+ FcResultMatch == FcPatternGetString (fc_font->font_pattern,
+ PANGO_FC_FONT_FEATURES,
+ num_features,
+ (FcChar8 **) &s))
+ {
+ features[num_features].tag = hb_tag_from_string (s, -1);
+ features[num_features].value = 1;
+ features[num_features].start = 0;
+ features[num_features].end = (unsigned int) -1;
+ num_features++;
+ }
+ }
+
+ hb_shape (hb_font, hb_buffer, features, num_features);
if (PANGO_GRAVITY_IS_IMPROPER (analysis->gravity))
hb_buffer_reverse (hb_buffer);
diff --git a/pango/pangofc-fontmap.h b/pango/pangofc-fontmap.h
index 3809446b..73d1cc99 100644
--- a/pango/pangofc-fontmap.h
+++ b/pango/pangofc-fontmap.h
@@ -266,6 +266,20 @@ PangoFontDescription *pango_fc_font_description_from_pattern (FcPattern *pattern
*/
#define PANGO_FC_PRGNAME "pangoprgname"
+/**
+ * PANGO_FC_FONT_FEATURES:
+ *
+ * String representing a fontconfig property name that Pango reads from font
+ * patterns to populate list of OpenType features to be enabled for the font
+ * by default.
+ *
+ * The property will have a number of string elements, each of which is the
+ * OpenType feature tag of one feature to enable.
+ *
+ * Since: 1.34
+ */
+#define PANGO_FC_FONT_FEATURES "pangofontfeatures"
+
G_END_DECLS
#endif /* __PANGO_FC_FONT_MAP_H__ */