[pango/pango2: 57/301] itemize: Break paragraph separators
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2: 57/301] itemize: Break paragraph separators
- Date: Wed, 22 Jun 2022 15:53:34 +0000 (UTC)
commit d3a384f11245c24654552dc0e519df42721d2656
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jan 14 20:23:12 2022 -0500
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.
pango/itemize.c | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/pango/itemize.c b/pango/itemize.c
index 05ad5ba51..efc45d569 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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]