diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2015-06-18 11:49:40 -0700 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2015-06-18 11:49:40 -0700 |
commit | ba53f29f7c2c105becb898d6417a4c160b7fc1e5 (patch) | |
tree | 3bf0d589b0d549192fbbe0dc321fcd4235c416d6 /pango/pango-attributes.c | |
parent | dfe7ec760e08485520668ed1e2585c85545fc013 (diff) | |
download | pango-ba53f29f7c2c105becb898d6417a4c160b7fc1e5.tar.gz |
Bug 738505 - Add fontfeatures support in PangoAttributes and markup
https://bugzilla.gnome.org/show_bug.cgi?id=738505
Patch from Matthias Clasen, based on early patch from Akira TAGOH.
There's room for improvement in how this is done, but it works now
for simple cases, which is what most people will be using it for.
Finally!
Diffstat (limited to 'pango/pango-attributes.c')
-rw-r--r-- | pango/pango-attributes.c | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c index 72455acd..da9fefeb 100644 --- a/pango/pango-attributes.c +++ b/pango/pango-attributes.c @@ -1101,6 +1101,31 @@ pango_attr_gravity_hint_new (PangoGravityHint hint) return pango_attr_int_new (&klass, (int)hint); } +/** + * pango_attr_font_features_new: + * @features: a string with OpenType font features, in CSS syntax + * + * Create a new font features tag attribute. + * + * Return value: (transfer full): the newly allocated #PangoAttribute, + * which should be freed with pango_attribute_destroy(). + * + * Since: 1.38 + **/ +PangoAttribute * +pango_attr_font_features_new (const gchar *features) +{ + static const PangoAttrClass klass = { + PANGO_ATTR_FONT_FEATURES, + pango_attr_string_copy, + pango_attr_string_destroy, + pango_attr_string_equal + }; + + g_return_val_if_fail (features != NULL, NULL); + + return pango_attr_string_new (&klass, features); +} /* * Attribute List @@ -1928,17 +1953,21 @@ pango_attr_iterator_get_font (PangoAttrIterator *iterator, gboolean found = FALSE; tmp_list2 = *extra_attrs; - while (tmp_list2) - { - PangoAttribute *old_attr = tmp_list2->data; - if (attr->klass->type == old_attr->klass->type) - { - found = TRUE; - break; - } - - tmp_list2 = tmp_list2->next; - } + /* Hack: special-case FONT_FEATURES. We don't want them to + * override each other, so we never merge them. This should + * be fixed when we implement attr-merging. */ + if (attr->klass->type != PANGO_ATTR_FONT_FEATURES) + while (tmp_list2) + { + PangoAttribute *old_attr = tmp_list2->data; + if (attr->klass->type == old_attr->klass->type) + { + found = TRUE; + break; + } + + tmp_list2 = tmp_list2->next; + } if (!found) *extra_attrs = g_slist_prepend (*extra_attrs, pango_attribute_copy (attr)); |