diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2012-04-24 19:55:18 -0700 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2012-04-24 19:57:23 -0700 |
commit | 3632b7f3ef0c6158507724a2496b24b457f3f007 (patch) | |
tree | a3ae849ce9f0c5672380b84ffe0ac14bd5c69038 /core/jni | |
parent | 003952ba33f711963ad26588b2aca293deb8d50a (diff) | |
download | frameworks_base-3632b7f3ef0c6158507724a2496b24b457f3f007.zip frameworks_base-3632b7f3ef0c6158507724a2496b24b457f3f007.tar.gz frameworks_base-3632b7f3ef0c6158507724a2496b24b457f3f007.tar.bz2 |
Improve char mirroring in TextLayoutCache
- now use ICU u_isMirrored() instead of a small hardcoded list of unicode points
see bug #5961254 Harfbuzz should be able to support Bidi_mirrored unicode attribute
Change-Id: I3243a58558a97930f0e7fdf5e9c1d5695d9393de
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/android/graphics/TextLayoutCache.cpp | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/core/jni/android/graphics/TextLayoutCache.cpp b/core/jni/android/graphics/TextLayoutCache.cpp index a97c710..928094a 100644 --- a/core/jni/android/graphics/TextLayoutCache.cpp +++ b/core/jni/android/graphics/TextLayoutCache.cpp @@ -21,6 +21,7 @@ #include "SkFontHost.h" #include <unicode/unistr.h> #include <unicode/normlzr.h> +#include <unicode/uchar.h> extern "C" { #include "harfbuzz-unicode.h" @@ -39,8 +40,6 @@ namespace android { ANDROID_SINGLETON_STATIC_INSTANCE(TextLayoutEngine); -static KeyedVector<UChar, UChar> gBidiMirrored; - //-------------------------------------------------------------------------------------------------- TextLayoutCache::TextLayoutCache(TextLayoutShaper* shaper) : @@ -356,23 +355,6 @@ TextLayoutShaper::TextLayoutShaper() : mShaperItemGlyphArraySize(0) { mShaperItem.font = &mFontRec; mShaperItem.font->userData = &mShapingPaint; - - // Fill the BiDi mirrored chars map - // See: http://www.unicode.org/Public/6.0.0/ucd/extracted/DerivedBinaryProperties.txt - gBidiMirrored.add('(', ')'); - gBidiMirrored.add(')', '('); - gBidiMirrored.add('[', ']'); - gBidiMirrored.add(']', '['); - gBidiMirrored.add('{', '}'); - gBidiMirrored.add('}', '{'); - gBidiMirrored.add('<', '>'); - gBidiMirrored.add('>', '<'); - gBidiMirrored.add(0x00ab, 0x00bb); // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK - gBidiMirrored.add(0x00bb, 0x00ab); // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK - gBidiMirrored.add(0x2039, 0x203a); // SINGLE LEFT-POINTING ANGLE QUOTATION MARK - gBidiMirrored.add(0x203a, 0x2039); // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK - gBidiMirrored.add(0x2264, 0x2265); // LESS-THAN OR EQUAL TO - gBidiMirrored.add(0x2265, 0x2264); // GREATER-THAN OR EQUAL TO } TextLayoutShaper::~TextLayoutShaper() { @@ -577,7 +559,7 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* chars #if DEBUG_GLYPHS ALOGD("Found main code point at index %d", int(j)); #endif - // We found the main code point, so we can normalize the "chunck" and fill + // We found the main code point, so we can normalize the "chunk" and fill // the remaining with ZWSP so that the Paint.getTextWidth() APIs will still be able // to get one advance per char mBuffer.remove(); @@ -608,17 +590,13 @@ void TextLayoutShaper::computeRunValues(const SkPaint* paint, const UChar* chars // script-run splitting with Harfbuzz is splitting on parenthesis if (isRTL) { for (ssize_t i = 0; i < ssize_t(count); i++) { - UChar ch = chars[i]; - ssize_t index = gBidiMirrored.indexOfKey(ch); - // Skip non "BiDi mirrored" chars - if (index < 0) { - continue; - } + UChar32 ch = chars[i]; + if (!u_isMirrored(ch)) continue; if (!useNormalizedString) { useNormalizedString = true; mNormalizedString.setTo(false /* not terminated*/, chars, count); } - UChar result = gBidiMirrored.valueAt(index); + UChar result = (UChar) u_charMirror(ch); mNormalizedString.setCharAt(i, result); #if DEBUG_GLYPHS ALOGD("Rewriting codepoint '%d' to '%d' at position %d", |