diff options
author | John Tapsell <john.tapsell.ext@basyskom.com> | 2012-02-08 10:12:16 +0000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-23 15:07:58 +0100 |
commit | 2b23d7214f1bb90369ee418a30958fcc5d96cd8f (patch) | |
tree | 32f57d64d34987276409ce7359284a1925c475b1 /src | |
parent | 785e95ef0a95ca8fb39ef57678cd4876ee657c43 (diff) |
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: I5ad0ddbc66ea96e08913446dad8fd3c5d5dd0905
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/text/qtextengine.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index bc7f4f7ad6..30170759a0 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -115,7 +115,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; |