diff options
author | Raph Levien <raph@google.com> | 2012-04-24 16:04:34 -0700 |
---|---|---|
committer | Raph Levien <raph@google.com> | 2012-04-24 16:04:34 -0700 |
commit | 57e9723134e295c75a5aa0b20ca4764fc3959d25 (patch) | |
tree | adb2a394ea1c780f411e472800bbbea8243dc91a /core/jni/android/graphics | |
parent | 1579a67ee9a53740a09e606e071fd571ee627449 (diff) | |
download | frameworks_base-57e9723134e295c75a5aa0b20ca4764fc3959d25.zip frameworks_base-57e9723134e295c75a5aa0b20ca4764fc3959d25.tar.gz frameworks_base-57e9723134e295c75a5aa0b20ca4764fc3959d25.tar.bz2 |
Partial fix for bug 6132077 (incorrect line breaking of Arabic text).
Fixed getTextRunAdvances so that advances are correctly aligned with
UTF-16 code point offices, rather than runs being reversed in RTL.
Change-Id: Ife59c0c26f745654c16656c86072e9102d8f6bc7
Diffstat (limited to 'core/jni/android/graphics')
-rw-r--r-- | core/jni/android/graphics/TextLayoutCache.cpp | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp index a97c710..684cc87 100644 --- a/core/jni/android/graphics/TextLayoutCache.cpp +++ b/core/jni/android/graphics/TextLayoutCache.cpp @@ -550,6 +550,10 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* chars return; } + // To be filled in later + for (size_t i = 0; i < count; i++) { + outAdvances->add(0); + } UErrorCode error = U_ZERO_ERROR; bool useNormalizedString = false; for (ssize_t i = count - 1; i >= 0; --i) { @@ -691,23 +695,11 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* chars logGlyphs(mShaperItem); #endif - if (isRTL) { - endScriptRun = startScriptRun; -#if DEBUG_GLYPHS - ALOGD("Updated endScriptRun = %d", int(endScriptRun)); -#endif - } else { - startScriptRun = endScriptRun; -#if DEBUG_GLYPHS - ALOGD("Updated startScriptRun = %d", int(startScriptRun)); -#endif - } if (mShaperItem.advances == NULL || mShaperItem.num_glyphs == 0) { #if DEBUG_GLYPHS ALOGD("Advances array is empty or num_glypth = 0"); #endif - outAdvances->insertAt(0, outAdvances->size(), countScriptRun); continue; } @@ -721,15 +713,13 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* chars // Get Advances and their total jfloat currentAdvance = HBFixedToFloat(mShaperItem.advances[mShaperItem.log_clusters[0]]); jfloat totalFontRunAdvance = currentAdvance; - outAdvances->add(currentAdvance); + outAdvances->replaceAt(currentAdvance, startScriptRun); for (size_t i = 1; i < countScriptRun; i++) { size_t clusterPrevious = mShaperItem.log_clusters[i - 1]; size_t cluster = mShaperItem.log_clusters[i]; - if (cluster == clusterPrevious) { - outAdvances->add(0); - } else { + if (cluster != clusterPrevious) { currentAdvance = HBFixedToFloat(mShaperItem.advances[mShaperItem.log_clusters[i]]); - outAdvances->add(currentAdvance); + outAdvances->replaceAt(currentAdvance, startScriptRun + i); } } // TODO: can be removed and go back in the previous loop when Harfbuzz log clusters are fixed @@ -746,6 +736,7 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* chars (*outAdvances)[i], mShaperItem.log_clusters[i], totalFontRunAdvance); } #endif + // Get Glyphs and reverse them in place if RTL if (outGlyphs) { size_t countGlyphs = mShaperItem.num_glyphs; |