From 60ca03709c7e9845b997520dab70ac1ac76787dd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 20 Apr 2009 12:51:57 +0200 Subject: Change QFontMetrics::width to return the width of the longest variant if the string is a multi-length one Task-number: QT-10 Reviewed-by: Oswald Buddenhagen --- src/gui/text/qfontmetrics.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index 5c5320f..4229d5b 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -528,12 +528,14 @@ int QFontMetrics::rightBearing(QChar ch) const */ int QFontMetrics::width(const QString &text, int len) const { + int pos = text.indexOf(QLatin1Char('\x9c')); + QString txt = (pos == -1) ? text : text.left(pos); if (len < 0) - len = text.length(); + len = txt.length(); if (len == 0) return 0; - QTextEngine layout(text, d); + QTextEngine layout(txt, d); layout.ignoreBidi = true; return qRound(layout.width(0, len)); } -- cgit v0.12