diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-12-06 22:57:27 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-12-06 23:20:00 -0500 |
commit | dc5b1fdea7d63277f2b31489896d1947f0511a24 (patch) | |
tree | ac8caa284c779226c4272bab6739c9f2d486e712 /pango/pango-layout.c | |
parent | 1cf8e9b3cadad6efe510a177ca2be8f852022333 (diff) | |
download | pango-dc5b1fdea7d63277f2b31489896d1947f0511a24.tar.gz |
Fix line width computation
We an only use the line_width - remaining_width
shortcut if we are actually maintaining remaining_width,
i.e. not if we don't wrap lines.
Testcase included.
Fixes: #635
Diffstat (limited to 'pango/pango-layout.c')
-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; |