summaryrefslogtreecommitdiff
path: root/pango/break.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-07-14 12:06:18 -0400
committerMatthias Clasen <mclasen@redhat.com>2019-07-16 10:22:20 -0400
commit13103cdcf4e73d9b3dbc41deeecc136baa490e8d (patch)
tree42b1a520120bb0217fdac85d26afcd972fa9672a /pango/break.c
parentd9569d06cf3b3027ab4f9512703a56745d7074cc (diff)
downloadpango-13103cdcf4e73d9b3dbc41deeecc136baa490e8d.tar.gz
Add pango_tailor_break
This function lets you apply language-specific tailoring on top of breaks produced by pango_default_break.
Diffstat (limited to 'pango/break.c')
-rw-r--r--pango/break.c58
1 files changed, 42 insertions, 16 deletions
diff --git a/pango/break.c b/pango/break.c
index 11a1e34a..0b3f908a 100644
--- a/pango/break.c
+++ b/pango/break.c
@@ -1721,6 +1721,43 @@ pango_find_paragraph_boundary (const gchar *text,
*next_paragraph_start = start - text;
}
+/**
+ * pango_tailor_break:
+ * @text: text to process. Must be valid UTF-8
+ * @length: length in bytes of @text
+ * @analysis: #PangoAnalysis structure from pango_itemize() for @text
+ * @log_attrs: (array length=attrs_len): array with one #PangoLogAttr
+ * per character in @text, plus one extra, to be filled in
+ * @attrs_len: length of @log_attrs array
+ *
+ * Apply language-specific tailoring to the breaks in
+ * @log_attrs, which are assumed to have been produced
+ * by pango_default_break().
+ */
+void
+pango_tailor_break (const char *text,
+ int length,
+ PangoAnalysis *analysis,
+ PangoLogAttr *log_attrs,
+ int log_attrs_len)
+{
+ PangoLogAttr *start = log_attrs;
+ PangoLogAttr attr_before = *start;
+
+ if (tailor_break (text, length, analysis, log_attrs, log_attrs_len))
+ {
+ /* if tailored, we enforce some of the attrs from before
+ * tailoring at the boundary
+ */
+
+ start->backspace_deletes_character = attr_before.backspace_deletes_character;
+
+ start->is_line_break |= attr_before.is_line_break;
+ start->is_mandatory_break |= attr_before.is_mandatory_break;
+ start->is_cursor_position |= attr_before.is_cursor_position;
+ }
+}
+
static int
tailor_segment (const char *range_start,
const char *range_end,
@@ -1734,22 +1771,11 @@ tailor_segment (const char *range_start,
chars_in_range = pango_utf8_strlen (range_start, range_end - range_start);
- if (tailor_break (range_start,
- range_end - range_start,
- analysis,
- start,
- chars_in_range + 1))
- {
- /* if tailored, we enforce some of the attrs from before tailoring at
- * the boundary
- */
-
- start->backspace_deletes_character = attr_before.backspace_deletes_character;
-
- start->is_line_break |= attr_before.is_line_break;
- start->is_mandatory_break |= attr_before.is_mandatory_break;
- start->is_cursor_position |= attr_before.is_cursor_position;
- }
+ pango_tailor_break (range_start,
+ range_end - range_start,
+ analysis,
+ start,
+ chars_in_range + 1);
return chars_in_range;
}