summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorJohn Tapsell <john.tapsell.ext@basyskom.com>2012-02-08 10:12:16 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-02-10 08:50:09 (GMT)
commit08dbc36a09e79fa07204164281030320db96926c (patch)
tree8a6501f12f8211431cf4df1c3947b3bf417dcced /src/gui/text
parentf1b994a14001ac50cacf111d2c3551ece7c406fd (diff)
downloadQt-08dbc36a09e79fa07204164281030320db96926c.zip
Qt-08dbc36a09e79fa07204164281030320db96926c.tar.gz
Qt-08dbc36a09e79fa07204164281030320db96926c.tar.bz2
QTextEngine - treat a fullstop (0x2E) as the same script as the preceeding text when dividing up strings
Many languages use a fullstop to indicate an abbreviation, making the fullstop part of the word. For languages like thai, it is required to pass the fullstop along for correct word breaking. Change-Id: Ideded63432d06a1ab3b786a7bd13356f2cc1a090 Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qtextengine.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index bd66689..effb6e1 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -114,7 +114,20 @@ private:
return;
const int end = start + length;
for (int i = start + 1; i < end; ++i) {
- if ((m_analysis[i] == m_analysis[start])
+ // According to the unicode spec we should be treating characters in the Common script
+ // (punctuation, spaces, etc) as being the same script as the surrounding text for the
+ // purpose of splitting up text. This is important because, for example, a fullstop
+ // (0x2E) can be used to indicate an abbreviation and so must be treated as part of a
+ // word. Thus it must be passed along with the word in languages that have to calculate
+ // word breaks. For example the thai word "ครม." has no word breaks but the word "ครม"
+ // does.
+ // Unfortuntely because we split up the strings for both wordwrapping and for setting
+ // the font and because Japanese and Chinese are also aliases of the script "Common",
+ // doing this would break too many things. So instead we only pass the full stop
+ // along, and nothing else.
+ if (m_analysis[i].bidiLevel == m_analysis[start].bidiLevel
+ && m_analysis[i].flags == m_analysis[start].flags
+ && (m_analysis[i].script == m_analysis[start].script || m_string[i] == QLatin1Char('.'))
&& m_analysis[i].flags < QScriptAnalysis::SpaceTabOrObject
&& i - start < MaxItemLength)
continue;