summaryrefslogtreecommitdiff
path: root/pango/break.c
diff options
context:
space:
mode:
Diffstat (limited to 'pango/break.c')
-rw-r--r--pango/break.c76
1 files changed, 51 insertions, 25 deletions
diff --git a/pango/break.c b/pango/break.c
index 11a1e34a..8066fca0 100644
--- a/pango/break.c
+++ b/pango/break.c
@@ -146,13 +146,11 @@ typedef enum
* @attrs: logical attributes to fill in
* @attrs_len: size of the array passed as @attrs
*
- * This is the default break algorithm, used if no language
- * engine overrides it. Normally you should use pango_break()
- * instead. Unlike pango_break(),
- * @analysis can be %NULL, but only do that if you know what
- * you're doing. If you need an analysis to pass to pango_break(),
- * you need to pango_itemize(). In most cases however you should
- * simply use pango_get_log_attrs().
+ * This is the default break algorithm. It applies Unicode
+ * rules without language-specific tailoring, therefore
+ * the @analyis argument is unused and can be %NULL.
+ *
+ * See pango_tailor_break() for language-specific breaks.
**/
void
pango_default_break (const gchar *text,
@@ -1604,8 +1602,10 @@ tailor_break (const gchar *text,
* @attrs_len: size of the array passed as @attrs
*
* Determines possible line, word, and character breaks
- * for a string of Unicode text with a single analysis. For most
- * purposes you may want to use pango_get_log_attrs().
+ * for a string of Unicode text with a single analysis.
+ * For most purposes you may want to use pango_get_log_attrs().
+ *
+ * Deprecated: 1.44: Use pango_default_break() and pango_tailor_break()
*/
void
pango_break (const gchar *text,
@@ -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;
}