From b5871decc0d09a05de835aff09291c01c0116b3c Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Wed, 28 Oct 2015 13:58:11 +0100 Subject: [PATCH] Justify row correctly after double space The wordSpacing property of a QFont object applies only once when there are multiple spaces between words. Therefore Row::Element::countSeparators shall not count spaces, but groups of spaces. Fixes bug #9808. --- src/Row.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Row.cpp b/src/Row.cpp index 5bdcbe004b..bd0945961f 100644 --- a/src/Row.cpp +++ b/src/Row.cpp @@ -41,7 +41,19 @@ int Row::Element::countSeparators() const { if (type != STRING) return 0; - return count(str.begin(), str.end(), ' '); + // Consecutive spaces count as only one separator. + bool wasspace = false; + int nsep = 0; + for (size_t i = 0 ; i < str.size() ; ++i) { + if (str[i] == ' ') { + if (!wasspace) { + ++nsep; + wasspace = true; + } + } else + wasspace = false; + } + return nsep; }