summaryrefslogtreecommitdiffstats
path: root/src/kernel/tqtextengine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/tqtextengine.cpp')
-rw-r--r--src/kernel/tqtextengine.cpp107
1 files changed, 56 insertions, 51 deletions
diff --git a/src/kernel/tqtextengine.cpp b/src/kernel/tqtextengine.cpp
index 05cdbcc13..067a21740 100644
--- a/src/kernel/tqtextengine.cpp
+++ b/src/kernel/tqtextengine.cpp
@@ -800,72 +800,77 @@ static void calcLineBreaks(const TQString &str, TQCharAttributes *charAttributes
{
int len = str.length();
if (!len)
- return;
+ return;
const TQChar *uc = str.unicode();
int cls = lineBreakClass(*uc);
if (cls >= TQUnicodeTables::LineBreak_CM)
- cls = TQUnicodeTables::LineBreak_ID;
+ cls = TQUnicodeTables::LineBreak_ID;
charAttributes[0].softBreak = FALSE;
charAttributes[0].whiteSpace = (cls == TQUnicodeTables::LineBreak_SP);
charAttributes[0].charStop = TRUE;
- for (int i = 1; i < len; ++i) {
- int ncls = ::lineBreakClass(uc[i]);
- int category = ::category(uc[i]);
- if (category == TQChar::Mark_NonSpacing)
- goto nsm;
-
- if (category == TQChar::Other_Surrogate) {
- // char stop only on first pair
- if (uc[i].isHighSurrogate() && i < (len - 1) && uc[i + 1].isLowSurrogate())
- goto nsm;
- // ### correctly handle second surrogate
- }
-
- if (ncls == TQUnicodeTables::LineBreak_SP) {
- charAttributes[i].softBreak = FALSE;
- charAttributes[i].whiteSpace = TRUE;
- charAttributes[i].charStop = TRUE;
- cls = ncls;
- continue;
- }
+ bool prevIsHighSurrogate = uc[0].isHighSurrogate();
+ for (int i = 1; i < len; ++i)
+ {
+ // Don't stop on low surrogate characters of complete valid pairs
+ if (prevIsHighSurrogate && uc[i].isLowSurrogate())
+ {
+ prevIsHighSurrogate = false;
+ charAttributes[i].softBreak = FALSE;
+ charAttributes[i].whiteSpace = FALSE;
+ charAttributes[i].charStop = FALSE;
+ continue;
+ }
+ prevIsHighSurrogate = uc[i].isHighSurrogate();
+ int ncls = ::lineBreakClass(uc[i]);
+ int category = ::category(uc[i]);
+ if (category == TQChar::Mark_NonSpacing)
+ {
+ charAttributes[i].softBreak = FALSE;
+ charAttributes[i].whiteSpace = FALSE;
+ charAttributes[i].charStop = FALSE;
+ continue;
+ }
- if (cls == TQUnicodeTables::LineBreak_SA && ncls == TQUnicodeTables::LineBreak_SA) {
- // two complex chars (thai or lao), thai_attributes might override, but here
- // we do a best guess
- charAttributes[i].softBreak = TRUE;
- charAttributes[i].whiteSpace = FALSE;
- charAttributes[i].charStop = TRUE;
- cls = ncls;
- continue;
- }
- {
- int tcls = ncls;
- if (tcls >= TQUnicodeTables::LineBreak_SA)
- tcls = TQUnicodeTables::LineBreak_ID;
- if (cls >= TQUnicodeTables::LineBreak_SA)
- cls = TQUnicodeTables::LineBreak_ID;
-
- bool softBreak;
- int brk = breakTable[cls][tcls];
- if (brk == Ibk)
- softBreak = (cls == TQUnicodeTables::LineBreak_SP);
- else
- softBreak = (brk == Dbk);
-// tqDebug("char = %c %04x, cls=%d, ncls=%d, brk=%d soft=%d", uc[i].cell(), uc[i].unicode(), cls, ncls, brk, charAttributes[i].softBreak);
- charAttributes[i].softBreak = softBreak;
+ if (ncls == TQUnicodeTables::LineBreak_SP) {
+ charAttributes[i].softBreak = FALSE;
+ charAttributes[i].whiteSpace = TRUE;
+ charAttributes[i].charStop = TRUE;
+ cls = ncls;
+ continue;
+ }
+
+ if (cls == TQUnicodeTables::LineBreak_SA && ncls == TQUnicodeTables::LineBreak_SA)
+ {
+ // two complex chars (thai or lao), thai_attributes might override, but here
+ // we do a best guess
+ charAttributes[i].softBreak = TRUE;
charAttributes[i].whiteSpace = FALSE;
charAttributes[i].charStop = TRUE;
cls = ncls;
+ continue;
}
- continue;
- nsm:
- charAttributes[i].softBreak = FALSE;
- charAttributes[i].whiteSpace = FALSE;
- charAttributes[i].charStop = FALSE;
+
+ int tcls = ncls;
+ if (tcls >= TQUnicodeTables::LineBreak_SA)
+ tcls = TQUnicodeTables::LineBreak_ID;
+ if (cls >= TQUnicodeTables::LineBreak_SA)
+ cls = TQUnicodeTables::LineBreak_ID;
+
+ bool softBreak;
+ int brk = breakTable[cls][tcls];
+ if (brk == Ibk)
+ softBreak = (cls == TQUnicodeTables::LineBreak_SP);
+ else
+ softBreak = (brk == Dbk);
+ // tqDebug("char = %c %04x, cls=%d, ncls=%d, brk=%d soft=%d", uc[i].cell(), uc[i].unicode(), cls, ncls, brk, charAttributes[i].softBreak);
+ charAttributes[i].softBreak = softBreak;
+ charAttributes[i].whiteSpace = FALSE;
+ charAttributes[i].charStop = TRUE;
+ cls = ncls;
}
}