Changeset 62965 in webkit


Ignore:
Timestamp:
Jul 9, 2010 10:28:27 AM (14 years ago)
Author:
xji@chromium.org
Message:

2010-07-09 Xiaomei Ji <xji@chromium.org>

Reviewed by David Levin.

Fix characters with unicode-bidi-mirror property are not correctly
mirrored in Linux.
https://bugs.webkit.org/show_bug.cgi?id=41305

Since harfbuzz does not do mirroring, chromium should iterate each
character in the string and mirror it if needed before passing the
string to harfbuzz for shaping.

Test: fast/text/international/bidi-mirror-he-ar.html

  • platform/graphics/chromium/FontLinux.cpp: (WebCore::TextRunWalker::TextRunWalker): (WebCore::TextRunWalker::~TextRunWalker): (WebCore::TextRunWalker::mirrorCharacters):

2010-07-09 Xiaomei Ji <xji@chromium.org>

Reviewed by David Levin.

Fix characters with unicode-bidi-mirror property are not correctly
mirrored in Linux.
https://bugs.webkit.org/show_bug.cgi?id=41305

Since harfbuzz does not do mirroring, chromium should iterate each
character in the string and mirror it if needed before passing the
string to harfbuzz for shaping.

  • fast/text/international/bidi-mirror-he-ar.html: Added.
  • platform/chromium-linux/fast/text/international/bidi-neutral-run-expected.checksum:
  • platform/chromium-linux/fast/text/international/bidi-neutral-run-expected.png:
  • platform/mac-snowleopard/platform/mac/fast/text: Added.
  • platform/mac-snowleopard/platform/mac/fast/text/international: Added.
  • platform/mac-snowleopard/platform/mac/fast/text/international/bidi-mirror-he-ar-expected.txt: Added.
  • platform/mac-tiger/fast/text/international/bidi-mirror-he-ar-expected.txt: Added.
  • platform/mac/fast/text/international/bidi-mirror-he-ar-expected.checksum: Added.
  • platform/mac/fast/text/international/bidi-mirror-he-ar-expected.png: Added.
  • platform/mac/fast/text/international/bidi-mirror-he-ar-expected.txt: Added.
Location:
trunk
Files:
8 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r62961 r62965  
     12010-07-09  Xiaomei Ji  <xji@chromium.org>
     2
     3        Reviewed by David Levin.
     4
     5        Fix characters with unicode-bidi-mirror property are not correctly
     6        mirrored in Linux.
     7        https://bugs.webkit.org/show_bug.cgi?id=41305
     8
     9        Since harfbuzz does not do mirroring, chromium should iterate each
     10        character in the string and mirror it if needed before passing the
     11        string to harfbuzz for shaping.
     12
     13        * fast/text/international/bidi-mirror-he-ar.html: Added.
     14        * platform/chromium-linux/fast/text/international/bidi-neutral-run-expected.checksum:
     15        * platform/chromium-linux/fast/text/international/bidi-neutral-run-expected.png:
     16        * platform/mac-snowleopard/platform/mac/fast/text: Added.
     17        * platform/mac-snowleopard/platform/mac/fast/text/international: Added.
     18        * platform/mac-snowleopard/platform/mac/fast/text/international/bidi-mirror-he-ar-expected.txt: Added.
     19        * platform/mac-tiger/fast/text/international/bidi-mirror-he-ar-expected.txt: Added.
     20        * platform/mac/fast/text/international/bidi-mirror-he-ar-expected.checksum: Added.
     21        * platform/mac/fast/text/international/bidi-mirror-he-ar-expected.png: Added.
     22        * platform/mac/fast/text/international/bidi-mirror-he-ar-expected.txt: Added.
     23
    1242010-07-09  Kenneth Russell  <kbr@google.com>
    225
  • trunk/LayoutTests/platform/chromium-linux/fast/text/international/bidi-neutral-run-expected.checksum

    r61917 r62965  
    1 2b95068560a3236bbda65c3178eb094a
     19d4749c11f04f98b76df497af3992899
  • trunk/WebCore/ChangeLog

    r62964 r62965  
     12010-07-09  Xiaomei Ji  <xji@chromium.org>
     2
     3        Reviewed by David Levin.
     4
     5        Fix characters with unicode-bidi-mirror property are not correctly
     6        mirrored in Linux.
     7        https://bugs.webkit.org/show_bug.cgi?id=41305
     8
     9        Since harfbuzz does not do mirroring, chromium should iterate each
     10        character in the string and mirror it if needed before passing the
     11        string to harfbuzz for shaping.
     12
     13        Test: fast/text/international/bidi-mirror-he-ar.html
     14
     15        * platform/graphics/chromium/FontLinux.cpp:
     16        (WebCore::TextRunWalker::TextRunWalker):
     17        (WebCore::TextRunWalker::~TextRunWalker):
     18        (WebCore::TextRunWalker::mirrorCharacters):
     19
     20
    1212010-07-09  Anders Carlsson  <andersca@apple.com>
    222
  • trunk/WebCore/platform/graphics/chromium/FontLinux.cpp

    r62798 r62965  
    5050#include <wtf/OwnArrayPtr.h>
    5151#include <wtf/OwnPtr.h>
     52#include <wtf/unicode/Unicode.h>
    5253
    5354namespace WebCore {
     
    181182        m_item.font = allocHarfbuzzFont();
    182183
    183         m_item.string = m_run.characters();
    184         m_item.stringLength = m_run.length();
    185184        m_item.item.bidiLevel = m_run.rtl();
     185
     186        int length = m_run.length();
     187        m_item.stringLength = length;
     188
     189        if (!m_item.item.bidiLevel)
     190            m_item.string = m_run.characters();
     191        else {
     192            // Assume mirrored character is in the same Unicode multilingual plane as the original one.
     193            UChar* string = new UChar[length];
     194            mirrorCharacters(string, m_run.characters(), length);
     195            m_item.string = string;
     196        }
    186197
    187198        reset();
     
    193204        deleteGlyphArrays();
    194205        delete[] m_item.log_clusters;
     206        if (m_item.item.bidiLevel)
     207            delete[] m_item.string;
    195208    }
    196209
     
    456469    }
    457470
     471    void mirrorCharacters(UChar* destination, const UChar* source, int length) const
     472    {
     473        int position = 0;
     474        bool error = false;
     475        // Iterate characters in source and mirror character if needed.
     476        while (position < length) {
     477            UChar32 character;
     478            int nextPosition = position;
     479            U16_NEXT(source, nextPosition, length, character);
     480            character = u_charMirror(character);
     481            U16_APPEND(destination, position, length, character, error);
     482            ASSERT(!error);
     483            position = nextPosition;
     484        }
     485    }
     486
    458487    const Font* const m_font;
    459488    HB_ShaperItem m_item;
Note: See TracChangeset for help on using the changeset viewer.