From a798b956b9786240a06142de078f56c28962a535 Mon Sep 17 00:00:00 2001 From: Konstantin Ritt Date: Tue, 25 Sep 2012 23:55:54 +0300 Subject: 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 --- src/3rdparty/harfbuzz/src/harfbuzz-shaper.h | 4 +++- src/3rdparty/harfbuzz/src/harfbuzz-thai.c | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/3rdparty/harfbuzz') 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); -- cgit v1.2.3