summaryrefslogtreecommitdiffstats
path: root/src/kernel/qscriptengine.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2025-02-04 17:59:57 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2025-02-09 19:21:23 +0900
commitfd79f0c8b020ff0c60b62c83745beb030ef38997 (patch)
tree9c9b0f1801b49d6d674685e257247db95df12a9f /src/kernel/qscriptengine.cpp
parent7f62b55432d2a5712694dec689f1ce4f07bc70a4 (diff)
downloadtqt-fd79f0c8b020ff0c60b62c83745beb030ef38997.tar.gz
tqt-fd79f0c8b020ff0c60b62c83745beb030ef38997.zip
Extend work on supporting surrogate characters done in commit e0a38072
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it> (cherry picked from commit 486aa07930e7b6e900f77e64726c8cc4110511d8)
Diffstat (limited to 'src/kernel/qscriptengine.cpp')
-rw-r--r--src/kernel/qscriptengine.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/kernel/qscriptengine.cpp b/src/kernel/qscriptengine.cpp
index cc454d72f..93ffc0e7d 100644
--- a/src/kernel/qscriptengine.cpp
+++ b/src/kernel/qscriptengine.cpp
@@ -288,10 +288,21 @@ static void heuristicSetGlyphAttributes(TQShaperItem *item, const TQChar *uc, in
Q_ASSERT(item->num_glyphs <= length);
unsigned short *logClusters = item->log_clusters;
-
- int i;
- for (i = 0; i < length; ++i)
- logClusters[i] = i;
+ int glyph_pos = 0;
+ for (int i = 0; i < length; i++)
+ {
+ if (uc[i].isHighSurrogate() && i < (length - 1) && uc[i+1].isLowSurrogate())
+ {
+ logClusters[i] = glyph_pos;
+ logClusters[++i] = glyph_pos;
+ }
+ else
+ {
+ logClusters[i] = glyph_pos;
+ }
+ ++glyph_pos;
+ }
+ Q_ASSERT(glyph_pos == item->num_glyphs);
// first char in a run is never (treated as) a mark
int cStart = 0;
@@ -307,7 +318,7 @@ static void heuristicSetGlyphAttributes(TQShaperItem *item, const TQChar *uc, in
}
int lastCat = ::category(uc[0]);
- for (i = 1; i < length; ++i) {
+ for (int i = 1; i < length; ++i) {
int cat = ::category(uc[i]);
if (qIsZeroWidthChar(uc[i].unicode())) {
item->attributes[i].mark = FALSE;