diff options
author | Raph Levien <raph@google.com> | 2012-04-24 22:38:15 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-04-24 22:38:15 -0700 |
commit | 66556c730deba60288adf66ba1685a9d2c724aae (patch) | |
tree | 8dd9db9159709ed963050f25b52fcdb2f28c96c4 /core | |
parent | d3d3bec976c674bb4f797709ffbe6aeb4501b504 (diff) | |
parent | 3632b7f3ef0c6158507724a2496b24b457f3f007 (diff) | |
download | frameworks_base-66556c730deba60288adf66ba1685a9d2c724aae.zip frameworks_base-66556c730deba60288adf66ba1685a9d2c724aae.tar.gz frameworks_base-66556c730deba60288adf66ba1685a9d2c724aae.tar.bz2 |
Merge "Improve char mirroring in TextLayoutCache"
Diffstat (limited to 'core')
-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 684cc87..a33b46a 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() { @@ -581,7 +563,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(); @@ -612,17 +594,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", |