From 60ff6f21ac14083647be7a10dde3a00943a9970d Mon Sep 17 00:00:00 2001 From: "bashi@chromium.org" Date: Sun, 1 Jul 2012 23:08:01 +0000 Subject: [PATCH] Arabic shaping is incorrect if ZWNJ exist https://bugs.webkit.org/show_bug.cgi?id=89843 Reviewed by Dan Bernstein. Source/WebCore: mac port treats ZWJ (zero-width-joiner) and ZWNJ (zero-width-non-joiner) as a part of combining character sequence. This could cause a problem when the font doesn't have glyph mapping of ZWJ and ZWNJ. Suppose the text to be rendered is "U+0645(MEEM) U+06CC(FARSI YEH) U+200C(ZWNJ)". In this case, U+0645 and U+06CC are rendered in isolated form if the font doesn't have a glyph for ZWNJ. They should be joined. This patch changes handling of ZWJ and ZWNJ. Treats ZWJ and ZWNJ as base characters so that a complex text run isn't separate at the point of ZWJ and ZWNJ even the font doesn't contain glyphs for them. If ComplexTextController finds ZWJ, it doesn't split the current complex text run. Test: platform/mac/fast/text/arabic-zwj-and-zwnj.html * platform/graphics/mac/ComplexTextController.cpp: (WebCore::advanceByCombiningCharacterSequence): Don't treat ZWJ and ZWNJ as a part of combining character sequence. (WebCore::ComplexTextController::collectComplexTextRuns): Set fontData to nextFontData if the baseCharacter is ZWJ. LayoutTests: * platform/mac/fast/text/arabic-zwj-and-zwnj-expected.html: Added. * platform/mac/fast/text/arabic-zwj-and-zwnj.html: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121643 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 10 ++++++++++ .../fast/text/arabic-zwj-and-zwnj-expected.html | 19 +++++++++++++++++++ .../mac/fast/text/arabic-zwj-and-zwnj.html | 19 +++++++++++++++++++ Source/WebCore/ChangeLog | 22 ++++++++++++++++++++++ .../graphics/mac/ComplexTextController.cpp | 18 +++++++++++------- 5 files changed, 81 insertions(+), 7 deletions(-) create mode 100644 LayoutTests/platform/mac/fast/text/arabic-zwj-and-zwnj-expected.html create mode 100644 LayoutTests/platform/mac/fast/text/arabic-zwj-and-zwnj.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 0b0ec6b..c393376 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,13 @@ +2012-07-01 Kenichi Ishibashi + + Arabic shaping is incorrect if ZWNJ exist + https://bugs.webkit.org/show_bug.cgi?id=89843 + + Reviewed by Dan Bernstein. + + * platform/mac/fast/text/arabic-zwj-and-zwnj-expected.html: Added. + * platform/mac/fast/text/arabic-zwj-and-zwnj.html: Added. + 2012-07-01 Emil A Eklund Unreviewed rebaseline for mac post r121599. diff --git a/LayoutTests/platform/mac/fast/text/arabic-zwj-and-zwnj-expected.html b/LayoutTests/platform/mac/fast/text/arabic-zwj-and-zwnj-expected.html new file mode 100644 index 0000000..4448a3e --- /dev/null +++ b/LayoutTests/platform/mac/fast/text/arabic-zwj-and-zwnj-expected.html @@ -0,0 +1,19 @@ + + + + +

The first word contains ZWJ. The first word should be identical with the second word.

+
+میخور +
+
+میخور +
+ +

The last character of the first word is ZWNJ. The first word should be identical with the second word.

+
+می +
+
+می +
diff --git a/LayoutTests/platform/mac/fast/text/arabic-zwj-and-zwnj.html b/LayoutTests/platform/mac/fast/text/arabic-zwj-and-zwnj.html new file mode 100644 index 0000000..afb0086 --- /dev/null +++ b/LayoutTests/platform/mac/fast/text/arabic-zwj-and-zwnj.html @@ -0,0 +1,19 @@ + + + + +

The first word contains ZWJ. The first word should be identical with the second word.

+
+می‍خور +
+
+میخور +
+ +

The last character of the first word is ZWNJ. The first word should be identical with the second word.

+
+می‌ +
+
+می +
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index ab33aaf..443d101 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,25 @@ +2012-07-01 Kenichi Ishibashi + + Arabic shaping is incorrect if ZWNJ exist + https://bugs.webkit.org/show_bug.cgi?id=89843 + + Reviewed by Dan Bernstein. + + mac port treats ZWJ (zero-width-joiner) and ZWNJ (zero-width-non-joiner) as a part of combining + character sequence. This could cause a problem when the font doesn't have glyph mapping of ZWJ and ZWNJ. + Suppose the text to be rendered is "U+0645(MEEM) U+06CC(FARSI YEH) U+200C(ZWNJ)". In this case, U+0645 + and U+06CC are rendered in isolated form if the font doesn't have a glyph for ZWNJ. They should be joined. + + This patch changes handling of ZWJ and ZWNJ. Treats ZWJ and ZWNJ as base characters so that a complex text + run isn't separate at the point of ZWJ and ZWNJ even the font doesn't contain glyphs for them. + If ComplexTextController finds ZWJ, it doesn't split the current complex text run. + + Test: platform/mac/fast/text/arabic-zwj-and-zwnj.html + + * platform/graphics/mac/ComplexTextController.cpp: + (WebCore::advanceByCombiningCharacterSequence): Don't treat ZWJ and ZWNJ as a part of combining character sequence. + (WebCore::ComplexTextController::collectComplexTextRuns): Set fontData to nextFontData if the baseCharacter is ZWJ. + 2012-07-01 Konrad Piascik [EFL] [GTK] [QT] fast/viewport/viewport-91.html is failing after r121555 diff --git a/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp b/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp index 6614adb..a9324d3 100644 --- a/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp +++ b/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp @@ -208,7 +208,7 @@ static bool advanceByCombiningCharacterSequence(const UChar*& iterator, const UC UChar32 nextCharacter; int markLength = 0; U16_NEXT(iterator, markLength, end - iterator, nextCharacter); - if (!(U_GET_GC_MASK(nextCharacter) & U_GC_M_MASK) && nextCharacter != zeroWidthJoiner && nextCharacter != zeroWidthNonJoiner) + if (!(U_GET_GC_MASK(nextCharacter) & U_GC_M_MASK)) break; markCount += markLength; iterator += markLength; @@ -284,13 +284,17 @@ void ComplexTextController::collectComplexTextRuns() } nextIsMissingGlyph = false; + if (baseCharacter == zeroWidthJoiner) + nextFontData = fontData; #if !PLATFORM(WX) - nextFontData = m_font.fontDataForCombiningCharacterSequence(cp + index, curr - cp - index, nextIsSmallCaps ? SmallCapsVariant : NormalVariant); - if (!nextFontData) { - if (markCount) - nextFontData = systemFallbackFontData(); - else - nextIsMissingGlyph = true; + else { + nextFontData = m_font.fontDataForCombiningCharacterSequence(cp + index, curr - cp - index, nextIsSmallCaps ? SmallCapsVariant : NormalVariant); + if (!nextFontData) { + if (markCount) + nextFontData = systemFallbackFontData(); + else + nextIsMissingGlyph = true; + } } #endif -- 2.7.4