summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
diff options
context:
space:
mode:
authorJohn Tapsell <john.tapsell.ext@basyskom.com>2012-03-09 23:08:49 +0000
committerQt by Nokia <qt-info@nokia.com>2012-03-20 11:44:09 +0100
commitadd629d4f16a536fc56d55727195e3247b621a54 (patch)
treef0979de59fd57c5cfefe3b3defea7a5cb8523d51 /src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
parent497f4fffa26ec9ad786752819119767b247bb247 (diff)
Harfbuzz-shaper - fix incorrect logClusters being set in HB_OpenTypePosition
After shaping in HB_OpenTypePosition, when we come to calculate the new logClusters array we have to take into account that the glyphs passed in are not a 1 to 1 correspondance with the original string, because some shaping might have already been done. So we must use the old logClusters values (stored in tmpLogClusters) to map from the glyphs passed in back to the original string. This fixes visual word wrapping problems in thai Change-Id: I384dfa98f0946e9e074728f89542acb2b6b6bc27 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp')
-rw-r--r--src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp48
1 files changed, 35 insertions, 13 deletions
diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
index f6900325bc..e630ec3808 100644
--- a/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
+++ b/src/3rdparty/harfbuzz/src/harfbuzz-shaper.cpp
@@ -1302,30 +1302,52 @@ HB_Bool HB_OpenTypePosition(HB_ShaperItem *item, int availableGlyphs, HB_Bool do
glyphs[i] = face->buffer->in_string[i].gindex;
attributes[i] = face->tmpAttributes[face->buffer->in_string[i].cluster];
if (i && face->buffer->in_string[i].cluster == face->buffer->in_string[i-1].cluster)
- attributes[i].clusterStart = false;
+ attributes[i].clusterStart = false; //FIXME - Shouldn't we otherwise set this to true, rather than leaving it?
}
item->num_glyphs = face->buffer->in_length;
if (doLogClusters && face->glyphs_substituted) {
// we can't do this for indic, as we pass the stuf in syllables and it's easier to do it in the shaper.
- unsigned short *logClusters = item->log_clusters;
- int clusterStart = 0;
- int oldCi = 0;
// #### the reconstruction of the logclusters currently does not work if the original string
// contains surrogate pairs
+
+ unsigned short *logClusters = item->log_clusters;
+ int clusterStart = 0;
+ int oldIntermediateIndex = 0;
+
+ // This code makes a mapping, logClusters, between the original utf16 string (item->string) and the final
+ // set of glyphs (in_string).
+ //
+ // The code sets the value of logClusters[i] to the index of in_string containing the glyph that will render
+ // item->string[i].
+ //
+ // This is complicated slightly because in_string[i].cluster is an index to an intermediate
+ // array of glyphs - the array that we were passed as the original value of item->glyphs.
+ // To map from the original string to the intermediate array of glyphs we have tmpLogClusters.
+ //
+ // So we have three groups of indexes:
+ //
+ // i,clusterStart = index to in_length, the final set of glyphs. Also an index to attributes
+ // intermediateIndex = index to the glyphs originally passed in.
+ // stringIndex = index to item->string, the original string.
+
+ int stringIndex = 0;
+ // Iterate over the final set of glyphs...
for (unsigned int i = 0; i < face->buffer->in_length; ++i) {
- int ci = face->buffer->in_string[i].cluster;
- // DEBUG(" ci[%d] = %d mark=%d, cmb=%d, cs=%d",
- // i, ci, glyphAttributes[i].mark, glyphAttributes[i].combiningClass, glyphAttributes[i].clusterStart);
- if (!attributes[i].mark && attributes[i].clusterStart && ci != oldCi) {
- for (int j = oldCi; j < ci; j++)
- logClusters[j] = clusterStart;
+ // Get the index into the intermediate string for the start of the cluster of chars
+ int intermediateIndex = face->buffer->in_string[i].cluster;
+ if (intermediateIndex != oldIntermediateIndex) {
+ // We have found the end of the cluster of chars in the intermediate string
+ while (face->tmpLogClusters[stringIndex] < intermediateIndex) {
+ logClusters[stringIndex++] = clusterStart;
+ }
clusterStart = i;
- oldCi = ci;
+ oldIntermediateIndex = intermediateIndex;
}
}
- for (int j = oldCi; j < face->length; j++)
- logClusters[j] = clusterStart;
+ while (stringIndex < face->length) {
+ logClusters[stringIndex++] = clusterStart;
+ }
}
// calulate the advances for the shaped glyphs