From 107ade7182f5a110b8717c2080c777c5c7c2cd44 Mon Sep 17 00:00:00 2001 From: Noah Levitt Date: Thu, 4 Dec 2003 23:11:28 +0000 Subject: Honor U+2028 LINE SEPARATOR. (#85745) 2003-12-04 Noah Levitt * pango/pango-context.c: * pango/pango-layout.c: Honor U+2028 LINE SEPARATOR. (#85745) --- pango/pango-context.c | 12 ++++++++---- pango/pango-layout.c | 23 ++++++++++++++++++++--- 2 files changed, 28 insertions(+), 7 deletions(-) (limited to 'pango') diff --git a/pango/pango-context.c b/pango/pango-context.c index 50df5077..3bd7fd28 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -933,7 +933,11 @@ static void itemize_state_process_run (ItemizeState *state) { const char *p; - gboolean last_was_tab = FALSE; + gboolean last_was_forced_break = FALSE; + + /* Only one character has type G_UNICODE_LINE_SEPARATOR in Unicode 4.0; + * update this if that changes. */ +#define LINE_SEPARATOR 0x2028 itemize_state_update_for_new_run (state); @@ -942,7 +946,7 @@ itemize_state_process_run (ItemizeState *state) p = g_utf8_next_char (p)) { gunichar wc = g_utf8_get_char (p); - gboolean is_tab = wc == '\t'; + gboolean is_forced_break = (wc == '\t' || wc == LINE_SEPARATOR); PangoEngineShape *shape_engine; PangoFont *font; @@ -956,10 +960,10 @@ itemize_state_process_run (ItemizeState *state) itemize_state_add_character (state, shape_engine, font, - is_tab || last_was_tab, + is_forced_break || last_was_forced_break, p); - last_was_tab = is_tab; + last_was_forced_break = is_forced_break; } /* Finish the final item from the current segment */ diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 445caa1f..a4e532d1 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -2472,7 +2472,8 @@ typedef enum BREAK_NONE_FIT, BREAK_SOME_FIT, BREAK_ALL_FIT, - BREAK_EMPTY_FIT + BREAK_EMPTY_FIT, + BREAK_LINE_SEPARATOR } BreakResult; typedef struct _ParaBreakState ParaBreakState; @@ -2561,6 +2562,10 @@ process_item (PangoLayout *layout, int i; gboolean processing_new_item = FALSE; + /* Only one character has type G_UNICODE_LINE_SEPARATOR in Unicode 4.0; + * update this if that changes. */ +#define LINE_SEPARATOR 0x2028 + if (!state->glyphs) { state->glyphs = pango_glyph_string_new (); @@ -2582,8 +2587,15 @@ process_item (PangoLayout *layout, processing_new_item = TRUE; } + + if (g_utf8_get_char (layout->text + item->offset) == LINE_SEPARATOR) + { + insert_run (line, state, layout->text, item, TRUE); + state->log_widths_offset += item->num_chars; + return BREAK_LINE_SEPARATOR; + } - if (state->remaining_width < 0 && !no_break_at_end) /* Wrapping off */ + if (state->remaining_width < 0 && !no_break_at_end) /* Wrapping off */ { insert_run (line, state, layout->text, item, TRUE); @@ -2735,7 +2747,7 @@ process_line (PangoLayout *layout, old_num_chars = item->num_chars; old_remaining_width = state->remaining_width; first_item_in_line = line->runs != NULL; - + result = process_item (layout, line, state, !have_break, FALSE); switch (result) @@ -2779,6 +2791,11 @@ process_line (PangoLayout *layout, state->start_offset += old_num_chars - item->num_chars; goto done; + + case BREAK_LINE_SEPARATOR: + state->items = g_list_delete_link (state->items, state->items); + state->start_offset += old_num_chars; + goto done; } } -- cgit v1.2.1