diff options
author | claireho <chinglanho@gmail.com> | 2010-07-27 15:30:29 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-07-27 15:30:29 -0700 |
commit | 3705cddbdce6c7c8c2d3ab97314df61d9e316d4c (patch) | |
tree | a96f235175d696716e6fda49846dd7d415c01ec1 | |
parent | 339423d653ae9562eaf33b6dc0f96ea6ad59972d (diff) | |
parent | abb274d1eae5637eee465c5618aac1266d8ce695 (diff) | |
download | external_webkit-3705cddbdce6c7c8c2d3ab97314df61d9e316d4c.zip external_webkit-3705cddbdce6c7c8c2d3ab97314df61d9e316d4c.tar.gz external_webkit-3705cddbdce6c7c8c2d3ab97314df61d9e316d4c.tar.bz2 |
Merge "Bug 2811402:Fixed parenthesis are not mirrored correctly in bidi layout."
-rw-r--r-- | WebCore/platform/graphics/android/FontAndroid.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/WebCore/platform/graphics/android/FontAndroid.cpp b/WebCore/platform/graphics/android/FontAndroid.cpp index 71d66e6..5bcb8d5 100644 --- a/WebCore/platform/graphics/android/FontAndroid.cpp +++ b/WebCore/platform/graphics/android/FontAndroid.cpp @@ -47,6 +47,7 @@ #include <unicode/uchar.h> #include <wtf/OwnArrayPtr.h> #include <wtf/OwnPtr.h> +#include <wtf/unicode/Unicode.h> #endif using namespace android; @@ -323,10 +324,20 @@ public: m_item.face = 0; m_item.font = allocHarfbuzzFont(); - m_item.string = m_run.characters(); - m_item.stringLength = m_run.length(); m_item.item.bidiLevel = m_run.rtl(); + int length = m_run.length(); + m_item.stringLength = length; + + if (!m_item.item.bidiLevel) + m_item.string = m_run.characters(); + else { + // Assume mirrored character is in the same Unicode multilingual plane as the original one. + UChar* string = new UChar[length]; + mirrorCharacters(string, m_run.characters(), length); + m_item.string = string; + } + reset(); } @@ -335,6 +346,8 @@ public: fastFree(m_item.font); deleteGlyphArrays(); delete[] m_item.log_clusters; + if (m_item.item.bidiLevel) + delete[] m_item.string; } void reset() @@ -624,6 +637,22 @@ private: m_offsetX += m_pixelWidth; } + void mirrorCharacters(UChar* destination, const UChar* source, int length) const + { + int position = 0; + bool error = false; + // Iterate characters in source and mirror character if needed. + while (position < length) { + UChar32 character; + int nextPosition = position; + U16_NEXT(source, nextPosition, length, character); + character = u_charMirror(character); + U16_APPEND(destination, position, length, character, error); + ASSERT(!error); + position = nextPosition; + } + } + const Font* const m_font; HB_ShaperItem m_item; uint16_t* m_glyphs16; // A vector of 16-bit glyph ids. |