From 4099d40683fbce8429a00b26168fb93285fde007 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Sat, 17 Jul 2021 23:16:15 +0200 Subject: [PATCH] Change the way the element's width is updated. Remove the code that computed the width every 30 characters (yay!). Make sure that finalizeLast() is called after inserting a row element in a row in breakParagraph. --- src/Row.cpp | 15 +++------------ src/TextMetrics.cpp | 1 + 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/Row.cpp b/src/Row.cpp index 705a147389..3bc8ef0d51 100644 --- a/src/Row.cpp +++ b/src/Row.cpp @@ -370,8 +370,7 @@ void Row::finalizeLast() if (elt.change.changed()) changebar_ = true; - if (elt.type == STRING) { - dim_.wid -= elt.dim.wid; + if (elt.type == STRING && elt.dim.wid == 0) { elt.dim.wid = theFontMetrics(elt.font).width(elt.str); dim_.wid += elt.dim.wid; } @@ -401,16 +400,8 @@ void Row::add(pos_type const pos, char_type const c, e.row_flags = can_break ? CanBreakInside : Inline; elements_.push_back(e); } - if (back().str.length() % 30 == 0) { - dim_.wid -= back().dim.wid; - back().str += c; - back().endpos = pos + 1; - back().dim.wid = theFontMetrics(back().font).width(back().str); - dim_.wid += back().dim.wid; - } else { - back().str += c; - back().endpos = pos + 1; - } + back().str += c; + back().endpos = pos + 1; } diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp index b5ba9746b9..fa855e448e 100644 --- a/src/TextMetrics.cpp +++ b/src/TextMetrics.cpp @@ -1092,6 +1092,7 @@ RowList TextMetrics::breakParagraph(Row const & bigrow) const !elt.font.language()->wordWrap()); // a new element in the row rows.back().push_back(elt); + rows.back().finalizeLast(); pos = elt.endpos; // Go to next element -- 2.39.5