summaryrefslogtreecommitdiffstats
path: root/src/3rdparty
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2012-09-25 23:55:54 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-26 03:09:57 +0200
commita798b956b9786240a06142de078f56c28962a535 (patch)
tree2c96818276618e64fffda7e469ae54641c717a1b /src/3rdparty
parentaeb21c73c5e4fc585340145374800a5e285e7ab7 (diff)
QCharAttributes: add wordStart/wordEnd flags
A simple heuristic is used to detect the word beginning and ending by looking at the word break property value of surrounding characters. This behaves better than the white-spaces based implementation used before and makes it possible to tailor the default algorithm for complex scripts. BIG FAT WARNING: The QCharAttributes buffer now has to have a length of string length + 1 for the flags at end of text. Task-Id: QTBUG-6498 Change-Id: I5589b191ffde6a50d2af0c14a00430d3852c67b4 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Diffstat (limited to 'src/3rdparty')
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-shaper.h4
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-thai.c10
2 files changed, 12 insertions, 2 deletions
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h
index 2ff52eaf30..5a3329dd4b 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.h
@@ -133,7 +133,9 @@ typedef struct {
hb_bitfield sentenceBoundary : 1;
hb_bitfield lineBreak : 1;
hb_bitfield whiteSpace : 1; /* A unicode whitespace character */
- hb_bitfield unused : 3;
+ hb_bitfield wordStart : 1;
+ hb_bitfield wordEnd : 1;
+ hb_bitfield unused : 1;
} HB_CharAttributes;
void HB_GetTailoredCharAttributes(const HB_UChar16 *string, hb_uint32 stringLength,
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c
index 70c1d57ff1..f62a1b7159 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c
@@ -395,8 +395,10 @@ static void HB_ThaiAssignAttributes(const HB_UChar16 *string, hb_uint32 len, HB_
to_tis620(string, len, cstr);
for (i = 0; i < len; ++i) {
- attributes[i].lineBreak = FALSE;
attributes[i].wordBreak = FALSE;
+ attributes[i].wordStart = FALSE;
+ attributes[i].wordEnd = FALSE;
+ attributes[i].lineBreak = FALSE;
}
if (len > 128) {
@@ -411,11 +413,17 @@ static void HB_ThaiAssignAttributes(const HB_UChar16 *string, hb_uint32 len, HB_
if (break_positions) {
attributes[0].wordBreak = TRUE;
+ attributes[0].wordStart = TRUE;
+ attributes[0].wordEnd = FALSE;
numbreaks = th_brk((const unsigned char *)cstr, break_positions, brp_size);
for (i = 0; i < numbreaks; ++i) {
attributes[break_positions[i]].wordBreak = TRUE;
+ attributes[break_positions[i]].wordStart = TRUE;
+ attributes[break_positions[i]].wordEnd = TRUE;
attributes[break_positions[i]].lineBreak = TRUE;
}
+ if (numbreaks > 0)
+ attributes[break_positions[numbreaks - 1]].wordStart = FALSE;
if (break_positions != brp)
free(break_positions);