summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-01-14 20:23:12 -0500
committerMatthias Clasen <mclasen@redhat.com>2022-01-24 07:46:42 -0500
commit0ac72e0245635ac8ea7b971b2f7b774fd57be606 (patch)
tree80e917c5b5863fcdea2e14fa203e8a4929ac1d3a
parent47e0c65b6c2d355d04ef0c90cf6891de60d4c0e6 (diff)
downloadpango-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.c17
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 */