diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-07-16 23:10:20 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-07-16 23:10:20 +0000 |
commit | 8c7acb646dfbebd71db5a7310d2dc5dc7412dcfc (patch) | |
tree | 853af11169cb56789f583187d6d293bd2f4148c6 /pango/pango-layout.c | |
parent | c5aeaba0816f8adb6557d5306b65e85c254b400c (diff) | |
parent | cc9b0912566b7c3bd4c1b31b5e6dd8532f1794c1 (diff) | |
download | pango-8c7acb646dfbebd71db5a7310d2dc5dc7412dcfc.tar.gz |
Merge branch 'tailor-break' into 'master'
Tailor break
See merge request GNOME/pango!86
Diffstat (limited to 'pango/pango-layout.c')
-rw-r--r-- | pango/pango-layout.c | 82 |
1 files changed, 47 insertions, 35 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c index e0725adc..21897e29 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -3958,51 +3958,61 @@ process_line (PangoLayout *layout, state->line_start_offset = state->start_offset; } +static gboolean +can_break_together (PangoAnalysis *analysis1, + PangoAnalysis *analysis2) +{ + return analysis1->level == analysis2->level && + analysis1->script == analysis2->script && + analysis1->language == analysis2->language; +} + static void get_items_log_attrs (const char *text, + int length, GList *items, PangoLogAttr *log_attrs, - int para_delimiter_len) + int log_attrs_len) { int offset = 0; int index = 0; + int num_bytes = 0; + int num_chars = 0; + PangoAnalysis analysis = { NULL }; + GList *l; - while (items) - { - PangoItem tmp_item = *(PangoItem *)items->data; - - /* Accumulate all the consecutive items that match in language - * characteristics, ignoring font, style tags, etc. - */ - while (items->next) - { - PangoItem *next_item = items->next->data; - - /* FIXME: Handle language tags */ - tmp_item.length += next_item->length; - tmp_item.num_chars += next_item->num_chars; + analysis.level = -1; - items = items->next; - } + pango_default_break (text, length, &analysis, log_attrs, log_attrs_len); - /* Break the paragraph delimiters with the last item */ - if (items->next == NULL) - { - tmp_item.num_chars += pango_utf8_strlen (text + index + tmp_item.length, para_delimiter_len); - tmp_item.length += para_delimiter_len; - } - - /* XXX This is wrong. we should call pango_default_break on the entire - * layout text and then tailor_break on each language change, like - * pango_get_log_attrs does. - */ - pango_break (text + index, tmp_item.length, &tmp_item.analysis, - log_attrs + offset, tmp_item.num_chars + 1); + for (l = items; l; l = l->next) + { + PangoItem *item = l->data; - offset += tmp_item.num_chars; - index += tmp_item.length; + if (l == items) + { + analysis = item->analysis; + index = item->offset; + offset = 0; + } - items = items->next; + if (can_break_together (&analysis, &item->analysis)) + { + num_bytes += item->length; + num_chars += item->num_chars; + } + else + { + pango_tailor_break (text + index, + num_bytes, + &analysis, + log_attrs + offset, + num_chars + 1); + + analysis = item->analysis; + index += num_bytes; + offset += num_chars; + } } } @@ -4243,9 +4253,11 @@ pango_layout_check_lines (PangoLayout *layout) if (no_break_attrs) apply_no_break_attributes (state.items, no_break_attrs); - get_items_log_attrs (start, state.items, + get_items_log_attrs (start, + delimiter_index + delim_len, + state.items, layout->log_attrs + start_offset, - delim_len); + layout->n_chars + 1 - start_offset); state.base_dir = base_dir; state.line_of_par = 1; |