diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-12-07 04:28:00 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-12-07 04:28:00 +0000 |
commit | 8b46f5db285c6c661a2a7c28c5b354426a8d5c61 (patch) | |
tree | 12270307395f0e41111bbabeea783f75e3060b09 /pango | |
parent | 43470dcc035f8c8c3331cce380c834dcba7c2c89 (diff) | |
parent | dc5b1fdea7d63277f2b31489896d1947f0511a24 (diff) | |
download | pango-8b46f5db285c6c661a2a7c28c5b354426a8d5c61.tar.gz |
Merge branch 'fix-tabs-nowrap' into 'main'
Fix line width computation
Closes #635
See merge request GNOME/pango!535
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pango-layout.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c index ed46d57a..a495596c 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -3662,6 +3662,31 @@ get_decimal_prefix_width (PangoItem *item, g_free (log_widths); } +static int +line_width (ParaBreakState *state, + PangoLayoutLine *line) +{ + GSList *l; + int i; + int width = 0; + + if (state->remaining_width > -1) + return state->line_width - state->remaining_width; + + /* Compute the width of the line currently - inefficient, but easier + * than keeping the current width of the line up to date everywhere + */ + for (l = line->runs; l; l = l->next) + { + PangoLayoutRun *run = l->data; + + for (i = 0; i < run->glyphs->num_glyphs; i++) + width += run->glyphs->glyphs[i].geometry.width; + } + + return width; +} + static PangoGlyphString * shape_run (PangoLayoutLine *line, ParaBreakState *state, @@ -3671,7 +3696,7 @@ shape_run (PangoLayoutLine *line, PangoGlyphString *glyphs = pango_glyph_string_new (); if (layout->text[item->offset] == '\t') - shape_tab (line, &state->last_tab, &state->properties, state->line_width - state->remaining_width, item, glyphs); + shape_tab (line, &state->last_tab, &state->properties, line_width (state, line), item, glyphs); else { PangoShapeFlags shape_flags = PANGO_SHAPE_NONE; |