diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-08-21 23:54:03 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-08-25 01:08:02 -0400 |
commit | b614ea2b06b3c9defaceb92b6904fa8a92249abe (patch) | |
tree | c20fdc8a2dc8a85561e3a8df5bf147d3c2888cd5 /pango/pango-attributes.c | |
parent | 3aee7615e9a123ae750e49e9864bdaa4b267cdbb (diff) | |
download | pango-b614ea2b06b3c9defaceb92b6904fa8a92249abe.tar.gz |
Add segmentation attributesbreak-tailoring
Add attributes that let us override word and
sentence boundaries (and, indirectly, line breaks).
Tests included.
Diffstat (limited to 'pango/pango-attributes.c')
-rw-r--r-- | pango/pango-attributes.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c index 28dc4105..326234d2 100644 --- a/pango/pango-attributes.c +++ b/pango/pango-attributes.c @@ -1303,6 +1303,60 @@ pango_attr_show_new (PangoShowFlags flags) } /** + * pango_attr_word_new: + * + * Marks the range of the attribute as a single word. + * + * Note that this may require adjustments to word and + * sentence classification around the range. + * + * Return value: (transfer full): the newly allocated + * `PangoAttribute`, which should be freed with + * [method@Pango.Attribute.destroy] + * + * Since: 1.50 + */ +PangoAttribute * +pango_attr_word_new (void) +{ + static const PangoAttrClass klass = { + PANGO_ATTR_WORD, + pango_attr_int_copy, + pango_attr_int_destroy, + pango_attr_int_equal, + }; + + return pango_attr_int_new (&klass, 0); +} + +/** + * pango_attr_sentence_new: + * + * Marks the range of the attribute as a single sentence. + * + * Note that this may require adjustments to word and + * sentence classification around the range. + * + * Return value: (transfer full): the newly allocated + * `PangoAttribute`, which should be freed with + * [method@Pango.Attribute.destroy] + * + * Since: 1.50 + */ +PangoAttribute * +pango_attr_sentence_new (void) +{ + static const PangoAttrClass klass = { + PANGO_ATTR_SENTENCE, + pango_attr_int_copy, + pango_attr_int_destroy, + pango_attr_int_equal, + }; + + return pango_attr_int_new (&klass, 0); +} + +/** * pango_attr_overline_new: * @overline: the overline style * @@ -1477,6 +1531,8 @@ pango_attribute_as_int (PangoAttribute *attr) case PANGO_ATTR_OVERLINE: case PANGO_ATTR_ABSOLUTE_LINE_HEIGHT: case PANGO_ATTR_TEXT_TRANSFORM: + case PANGO_ATTR_WORD: + case PANGO_ATTR_SENTENCE: return (PangoAttrInt *)attr; default: |