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-markup.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-markup.c')
-rw-r--r-- | pango/pango-markup.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/pango/pango-markup.c b/pango/pango-markup.c index 22064103..a9df8ed0 100644 --- a/pango/pango-markup.c +++ b/pango/pango-markup.c @@ -1230,6 +1230,7 @@ span_parse_func (MarkupData *md G_GNUC_UNUSED, const char *show = NULL; const char *line_height = NULL; const char *text_transform = NULL; + const char *segment = NULL; g_markup_parse_context_get_position (context, &line_number, &char_number); @@ -1297,6 +1298,7 @@ span_parse_func (MarkupData *md G_GNUC_UNUSED, CHECK_ATTRIBUTE (strikethrough); CHECK_ATTRIBUTE (strikethrough_color); CHECK_ATTRIBUTE (style); + CHECK_ATTRIBUTE (segment); break; case 't': CHECK_ATTRIBUTE (text_transform); @@ -1712,7 +1714,7 @@ span_parse_func (MarkupData *md G_GNUC_UNUSED, gboolean b = FALSE; if (!span_parse_boolean ("allow_breaks", allow_breaks, &b, line_number, error)) - goto error; + goto error; add_attribute (tag, pango_attr_allow_breaks_new (b)); } @@ -1727,6 +1729,25 @@ span_parse_func (MarkupData *md G_GNUC_UNUSED, add_attribute (tag, pango_attr_insert_hyphens_new (b)); } + if (G_UNLIKELY (segment)) + { + if (strcmp (segment, "word") == 0) + add_attribute (tag, pango_attr_word_new ()); + else if (strcmp (segment, "sentence") == 0) + add_attribute (tag, pango_attr_sentence_new ()); + else + { + g_set_error (error, + G_MARKUP_ERROR, + G_MARKUP_ERROR_INVALID_CONTENT, + _("Value of 'segment' attribute on <span> tag on line %d " + "could not be parsed; should be one of 'word' or " + "'sentence', not '%s'"), + line_number, segment); + goto error; + } + } + return TRUE; error: |