diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2012-01-13 18:55:32 -0800 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2012-01-13 19:49:46 -0800 |
commit | 03e250aefa29387f30a01243682eab2371103f8e (patch) | |
tree | 4bca102253b7d3eba8aafd93d829772533b58233 | |
parent | d4a69b4a1cb5b52035345abd8cb9595ae4cf9fa5 (diff) | |
download | frameworks_base-03e250aefa29387f30a01243682eab2371103f8e.zip frameworks_base-03e250aefa29387f30a01243682eab2371103f8e.tar.gz frameworks_base-03e250aefa29387f30a01243682eab2371103f8e.tar.bz2 |
Fix bug #5870701 Thai text can be clipped when there are more glyphs generated than the initial number of code points
- compute total advances correctly by iterating on the advances array for up to mShaperItem.num_glyphs
- update unit tests
Change-Id: I00af68bef88702215e9222ed80dbffcc81df51a7
-rw-r--r-- | core/jni/android/graphics/TextLayoutCache.cpp | 15 | ||||
-rw-r--r-- | tests/BiDiTests/res/values/strings.xml | 1 | ||||
-rw-r--r-- | tests/BiDiTests/src/com/android/bidi/BiDiTestView.java | 6 |
3 files changed, 19 insertions, 3 deletions
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp index 75251c9..b8aaffe 100644 --- a/core/jni/android/graphics/TextLayoutCache.cpp +++ b/core/jni/android/graphics/TextLayoutCache.cpp @@ -659,6 +659,13 @@ void TextLayoutEngine::computeRunValues(SkPaint* paint, const UChar* chars, continue; } +#if DEBUG_GLYPHS + ALOGD("Returned logclusters"); + for (size_t i = 0; i < mShaperItem.num_glyphs; i++) { + ALOGD(" -- lc[%d] = %d, hb-adv[%d] = %0.2f", i, mShaperItem.log_clusters[i], + i, HBFixedToFloat(mShaperItem.advances[i])); + } +#endif // Get Advances and their total jfloat currentAdvance = HBFixedToFloat(mShaperItem.advances[mShaperItem.log_clusters[0]]); jfloat totalFontRunAdvance = currentAdvance; @@ -670,11 +677,14 @@ void TextLayoutEngine::computeRunValues(SkPaint* paint, const UChar* chars, outAdvances->add(0); } else { currentAdvance = HBFixedToFloat(mShaperItem.advances[mShaperItem.log_clusters[i]]); - totalFontRunAdvance += currentAdvance; outAdvances->add(currentAdvance); } } - + // 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; + } totalAdvance += totalFontRunAdvance; #if DEBUG_ADVANCES @@ -684,7 +694,6 @@ void TextLayoutEngine::computeRunValues(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; diff --git a/tests/BiDiTests/res/values/strings.xml b/tests/BiDiTests/res/values/strings.xml index b1f5e50..1d4fc84 100644 --- a/tests/BiDiTests/res/values/strings.xml +++ b/tests/BiDiTests/res/values/strings.xml @@ -50,5 +50,6 @@ <string name="rtl">"والحق أن تترك ونص"</string> <string name="composing">"\u0644\u0627"</string> <string name="url">www.amazon.co.uk/gp/aw/h.html/275-8912818-8203452</string> + <string name="pointer_location" msgid="6084434787496938001">"ตำแหน่งของตัวชี้"</string> </resources> diff --git a/tests/BiDiTests/src/com/android/bidi/BiDiTestView.java b/tests/BiDiTests/src/com/android/bidi/BiDiTestView.java index 0126dea..0b1974a 100644 --- a/tests/BiDiTests/src/com/android/bidi/BiDiTestView.java +++ b/tests/BiDiTests/src/com/android/bidi/BiDiTestView.java @@ -51,6 +51,7 @@ public class BiDiTestView extends View { private String MIXED_TEXT_1; private String HEBREW_TEXT; private String RTL_TEXT; + private String THAI_TEXT; private int currentTextSize; @@ -82,6 +83,7 @@ public class BiDiTestView extends View { MIXED_TEXT_1 = context.getString(R.string.mixed_text_1); HEBREW_TEXT = context.getString(R.string.hebrew_text); RTL_TEXT = context.getString(R.string.rtl); + THAI_TEXT = context.getString(R.string.pointer_location); } public void setCurrentTextSize(int size) { @@ -134,6 +136,10 @@ public class BiDiTestView extends View { // Test Hebrew deltaX = testString(canvas, RTL_TEXT, ORIGIN, ORIGIN + 14 * currentTextSize, false, false, Paint.DIRECTION_RTL, currentTextSize); + + // Test Thai + deltaX = testString(canvas, THAI_TEXT, ORIGIN, ORIGIN + 16 * currentTextSize, + false, false, Paint.DIRECTION_LTR, currentTextSize); } private int testString(Canvas canvas, String text, int x, int y, |