summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2013-01-10 16:25:11 -0600
committerBehdad Esfahbod <behdad@behdad.org>2013-01-10 16:27:04 -0600
commitdb410d8ebdbc5b697430617e761da6b5ce4940dd (patch)
treeaca2d521f4dff4a76f74ee9c9dcad3c2dd5e416c
parent0df2e9592be488dcb3f3edfdfae64086e924eb92 (diff)
downloadpango-db410d8ebdbc5b697430617e761da6b5ce4940dd.tar.gz
Let people enable font features through fontconfig snippets
Like this: <match target="font"> <edit name="pangofontfeatures" mode="append"> <string>smcp</string> <string>ss20</string> </edit> </match> Finally we are starting to see new features coming out of the HarfBuzz integration...
-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__ */