diff options
-rw-r--r-- | docs/pango-sections.txt | 2 | ||||
-rw-r--r-- | pango/break.c | 58 | ||||
-rw-r--r-- | pango/pango-break.h | 7 |
3 files changed, 51 insertions, 16 deletions
diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt index e20c917a..496db41a 100644 --- a/docs/pango-sections.txt +++ b/docs/pango-sections.txt @@ -23,6 +23,7 @@ pango_break pango_get_log_attrs pango_find_paragraph_boundary pango_default_break +pango_tailor_break PangoLogAttr <SUBSECTION> @@ -71,6 +72,7 @@ PANGO_CONTEXT_CLASS PANGO_IS_CONTEXT PANGO_IS_CONTEXT_CLASS PANGO_CONTEXT_GET_CLASS +PANGO_TYPE_ITEM <SUBSECTION Private> pango_context_get_type 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; } diff --git a/pango/pango-break.h b/pango/pango-break.h index b035506e..2824e37f 100644 --- a/pango/pango-break.h +++ b/pango/pango-break.h @@ -136,6 +136,13 @@ void pango_default_break (const gchar *text, PangoLogAttr *attrs, int attrs_len); +PANGO_AVAILABLE_IN_1_44 +void pango_tailor_break (const gchar *text, + int length, + PangoAnalysis *analysis, + PangoLogAttr *attrs, + int attrs_len); + G_END_DECLS #endif /* __PANGO_BREAK_H__ */ |