summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-04-20 10:51:57 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-08-11 17:14:52 (GMT)
commit60ca03709c7e9845b997520dab70ac1ac76787dd (patch)
tree2809a2e46b48859116ae3a95d137872859837099
parentcaebd2676dda37fb7ab11c3b994fd341f88b0de0 (diff)
downloadQt-60ca03709c7e9845b997520dab70ac1ac76787dd.zip
Qt-60ca03709c7e9845b997520dab70ac1ac76787dd.tar.gz
Qt-60ca03709c7e9845b997520dab70ac1ac76787dd.tar.bz2
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
-rw-r--r--src/gui/text/qfontmetrics.cpp6
1 files 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));
}