Commit d6be5636 authored by xji@chromium.org's avatar xji@chromium.org
Browse files

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.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@62965 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 037d9b4a
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.
2010-07-09 Kenneth Russell <kbr@google.com>
 
Reviewed by Dimitri Glazkov.
<html>
<head>
<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8">
<title>Test bidi mirroring in Hebrew and Arabic</title>
</head>
<body dir=rtl>
<p>This test tests bidi mirroring in Hebrew and Arabic</p>
<p>The parenthesis should be displayed as "(...)..." visually from left to right</p>
<div>&#x05e9(&#x05e9)</div> <!-- Hebrew letter treated as simple script -->
<div>&#x05c6(&#x05c6)</div> <!-- Hebrew letter treated as complex script -->
<div>&#x0644(&#x0644)</div> <!-- Arabic letter treated as complex script -->
</body>
</html>
2b95068560a3236bbda65c3178eb094a
\ No newline at end of file
9d4749c11f04f98b76df497af3992899
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {P} at (0,0) size 784x18
RenderText {#text} at (464,0) size 320x18
text run at (464,0) width 320: "This test tests bidi mirroring in Hebrew and Arabic"
RenderBlock {P} at (0,34) size 784x18
RenderText {#text} at (327,0) size 457x18
text run at (327,0) width 457: "The parenthesis should be displayed as \"(...)...\" visually from left to right"
RenderBlock {DIV} at (0,68) size 784x19
RenderText {#text} at (750,1) size 34x18
text run at (750,1) width 34 RTL: "\x{5E9}(\x{5E9})"
RenderBlock {DIV} at (0,87) size 784x18
RenderText {#text} at (762,0) size 22x18
text run at (762,0) width 22 RTL: "\x{5C6}(\x{5C6})"
RenderBlock {DIV} at (0,105) size 784x20
RenderText {#text} at (758,2) size 26x18
text run at (758,2) width 26 RTL: "\x{644}(\x{644})"
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {P} at (0,0) size 784x18
RenderText {#text} at (464,0) size 320x18
text run at (464,0) width 320: "This test tests bidi mirroring in Hebrew and Arabic"
RenderBlock {P} at (0,34) size 784x18
RenderText {#text} at (327,0) size 457x18
text run at (327,0) width 457: "The parenthesis should be displayed as \"(...)...\" visually from left to right"
RenderBlock {DIV} at (0,68) size 784x19
RenderText {#text} at (750,1) size 34x18
text run at (750,1) width 34 RTL: "\x{5E9}(\x{5E9})"
RenderBlock {DIV} at (0,87) size 784x18
RenderText {#text} at (750,0) size 34x18
text run at (750,0) width 34 RTL: "\x{5C6}(\x{5C6})"
RenderBlock {DIV} at (0,105) size 784x21
RenderText {#text} at (760,3) size 24x18
text run at (760,3) width 24 RTL: "\x{644}(\x{644})"
b39185ca33028772ede1b054b5364b7d
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {P} at (0,0) size 784x18
RenderText {#text} at (464,0) size 320x18
text run at (464,0) width 320: "This test tests bidi mirroring in Hebrew and Arabic"
RenderBlock {P} at (0,34) size 784x18
RenderText {#text} at (327,0) size 457x18
text run at (327,0) width 457: "The parenthesis should be displayed as \"(...)...\" visually from left to right"
RenderBlock {DIV} at (0,68) size 784x19
RenderText {#text} at (751,1) size 33x18
text run at (751,1) width 33 RTL: "\x{5E9}(\x{5E9})"
RenderBlock {DIV} at (0,87) size 784x18
RenderText {#text} at (750,0) size 34x18
text run at (750,0) width 34 RTL: "\x{5C6}(\x{5C6})"
RenderBlock {DIV} at (0,105) size 784x21
RenderText {#text} at (760,3) size 24x18
text run at (760,3) width 24 RTL: "\x{644}(\x{644})"
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 Anders Carlsson <andersca@apple.com>
 
Reviewed by Simon Fraser.
......@@ -49,6 +49,7 @@
#include <unicode/uchar.h>
#include <wtf/OwnArrayPtr.h>
#include <wtf/OwnPtr.h>
#include <wtf/unicode/Unicode.h>
namespace WebCore {
......@@ -180,10 +181,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();
}
......@@ -192,6 +203,8 @@ public:
fastFree(m_item.font);
deleteGlyphArrays();
delete[] m_item.log_clusters;
if (m_item.item.bidiLevel)
delete[] m_item.string;
}
void reset()
......@@ -455,6 +468,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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment