diff options
author | Matthias Clasen <mclasen@redhat.com> | 2022-01-14 20:23:12 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2022-01-24 07:46:42 -0500 |
commit | 0ac72e0245635ac8ea7b971b2f7b774fd57be606 (patch) | |
tree | 80e917c5b5863fcdea2e14fa203e8a4929ac1d3a | |
parent | 47e0c65b6c2d355d04ef0c90cf6891de60d4c0e6 (diff) | |
download | pango-0ac72e0245635ac8ea7b971b2f7b774fd57be606.tar.gz |
itemize: Break paragraph separators
We don't normally meet paragraph separators
in the text that gets itemized. But if we do,
we want them in their own items.
-rw-r--r-- | pango/itemize.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/pango/itemize.c b/pango/itemize.c index 01399b7e..26a19177 100644 --- a/pango/itemize.c +++ b/pango/itemize.c @@ -944,6 +944,7 @@ itemize_state_process_run (ItemizeState *state) const char *p; gboolean last_was_forced_break = FALSE; gboolean is_space; + gunichar prev_wc = 0; /* Only one character has type G_UNICODE_LINE_SEPARATOR in Unicode 4.0; * update this if that changes. */ @@ -959,7 +960,8 @@ itemize_state_process_run (ItemizeState *state) p = g_utf8_next_char (p)) { gunichar wc = g_utf8_get_char (p); - gboolean is_forced_break = (wc == '\t' || wc == LINE_SEPARATOR); + gboolean is_forced_break = wc == '\t' || wc == '\r' || wc == '\n' || + wc == 0x2028 || wc == 0x2029; PangoFont *font; int font_position; @@ -975,12 +977,17 @@ itemize_state_process_run (ItemizeState *state) is_space = FALSE; } - itemize_state_add_character (state, font, font_position, - is_forced_break || last_was_forced_break, - p, - is_space); + /* Don't break between \r and \n */ + if (prev_wc == '\r' && wc == '\n') + state->item->num_chars++; + else + itemize_state_add_character (state, font, font_position, + is_forced_break || last_was_forced_break, + p, + is_space); last_was_forced_break = is_forced_break; + prev_wc = wc; } /* Finish the final item from the current segment */ |