diff options
| author | Raph Levien <raph@google.com> | 2012-09-24 16:14:38 -0700 |
|---|---|---|
| committer | Raph Levien <raph@google.com> | 2012-09-24 16:14:38 -0700 |
| commit | 1b10241a8f0affab9f46719e46c6fedff9e69b8b (patch) | |
| tree | 63dc530a10abd9c421d315f9387c7ceb2cfc9899 | |
| parent | 4249be40bd1c51dae37c27f9450ed01f19edcbef (diff) | |
| download | frameworks_base-1b10241a8f0affab9f46719e46c6fedff9e69b8b.zip frameworks_base-1b10241a8f0affab9f46719e46c6fedff9e69b8b.tar.gz frameworks_base-1b10241a8f0affab9f46719e46c6fedff9e69b8b.tar.bz2 | |
Fix for bug 6936752 Tamil text gets truncated on right-hand side
The getTextRunAdvances() method wasn't accounting for the true width of
the text. On closer examination, in Tamil the clusters consist of a
number of glyphs each of which has a nonzero advance (in some other
scripts, the first glyph in the cluster has an advance, and others are
effectively zero). Previously, we were just using the advance of the
first glyph in the cluster. This patch changes the behavior to sum the
advances of all the glyphs within the cluster.
Change-Id: I77a51235f4bb0dfaa72cbb920a8c3b217ad25404
| -rw-r--r-- | core/jni/android/graphics/TextLayoutCache.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp index 8032ed8..ba8cea4 100644 --- a/core/jni/android/graphics/TextLayoutCache.cpp +++ b/core/jni/android/graphics/TextLayoutCache.cpp @@ -686,23 +686,24 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* chars i, HBFixedToFloat(mShaperItem.advances[i])); } #endif - // Get Advances and their total - jfloat currentAdvance = HBFixedToFloat(mShaperItem.advances[mShaperItem.log_clusters[0]]); - jfloat totalFontRunAdvance = currentAdvance; - outAdvances->replaceAt(currentAdvance, startScriptRun); - for (size_t i = 1; i < countScriptRun; i++) { - size_t clusterPrevious = mShaperItem.log_clusters[i - 1]; + jfloat totalFontRunAdvance = 0; + size_t clusterStart = 0; + for (size_t i = 0; i < countScriptRun; i++) { size_t cluster = mShaperItem.log_clusters[i]; - if (cluster != clusterPrevious) { - currentAdvance = HBFixedToFloat(mShaperItem.advances[mShaperItem.log_clusters[i]]); - outAdvances->replaceAt(currentAdvance, startScriptRun + i); + size_t clusterNext = i == countScriptRun - 1 ? mShaperItem.num_glyphs : + mShaperItem.log_clusters[i + 1]; + if (cluster != clusterNext) { + jfloat advance = 0; + // The advance for the cluster is the sum of the advances of all glyphs within + // the cluster. + for (size_t j = cluster; j < clusterNext; j++) { + advance += HBFixedToFloat(mShaperItem.advances[j]); + } + totalFontRunAdvance += advance; + outAdvances->replaceAt(advance, startScriptRun + clusterStart); + clusterStart = i + 1; } } - // TODO: can be removed and go back in the previous loop when Harfbuzz log clusters are fixed - for (size_t i = 1; i < mShaperItem.num_glyphs; i++) { - currentAdvance = HBFixedToFloat(mShaperItem.advances[i]); - totalFontRunAdvance += currentAdvance; - } #if DEBUG_ADVANCES ALOGD("Returned advances"); |
