Changeset 111589 in webkit


Ignore:
Timestamp:
Mar 21, 2012 12:04:30 PM (12 years ago)
Author:
xji@chromium.org
Message:

[chromium] Font fallback in cr-win is wrong for string contains zero-width-space.
https://bugs.webkit.org/show_bug.cgi?id=79961

Reviewed by Adam Barth.

Source/WebCore:

Treat zero-width-space (\u200B) as true for treatAsZeroWidthSpaceInComplexScipt().

  • platform/graphics/Font.h:

(WebCore::Font::treatAsZeroWidthSpaceInComplexScript):

  • platform/graphics/mac/ComplexTextController.cpp:

(WebCore::ComplexTextController::adjustGlyphsAndAdvances):

  • platform/graphics/win/UniscribeController.cpp:

(WebCore::UniscribeController::shapeAndPlaceItem):

LayoutTests:

  • fast/text/zero-width-characters-complex-script.html:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r111588 r111589  
     12012-03-21  Xiaomei Ji  <xji@chromium.org>
     2
     3        [chromium] Font fallback in cr-win is wrong for string contains zero-width-space.
     4        https://bugs.webkit.org/show_bug.cgi?id=79961
     5
     6        Reviewed by Adam Barth.
     7
     8        * fast/text/zero-width-characters-complex-script.html:
     9
    1102012-03-21  Emil A Eklund  <eae@chromium.org>
    211
  • trunk/LayoutTests/fast/text/zero-width-characters-complex-script.html

    r84264 r111589  
    22<script>
    33
    4 function testChar(ch)
     4function testChar(a, b, ch)
    55{
    66    // Strings a and b selected here do not have any 'interaction' between them.
    7     var a = "\u0915\u093E"
    8     var b = "\u0916";
    97    var span = document.getElementById("characters");
    108    span.firstChild.data = a + b;
     
    2220}
    2321
     22function testWithZeroWidthSpace(a, b) {
     23    var failedCount = 0;
     24
     25    for (var i = 1; i < 32; ++i)
     26        if (i != 9 && i != 10 && i != 13)
     27            failedCount += testChar(a, b, i);
     28
     29    for (var i = 0x7F; i < 0xA0; ++i)
     30        failedCount += testChar(a, b, i);
     31    failedCount += testChar(a, b, 0xAD);
     32
     33    // ZWJ (U+200C) and ZWNJ (U+200D) are excluded because they
     34    // can affect the rendering in complex script text.
     35    failedCount += testChar(a, b, 0x200B);
     36    failedCount += testChar(a, b, 0x200E);
     37    failedCount += testChar(a, b, 0x200F);
     38    failedCount += testChar(a, b, 0x202A);
     39    failedCount += testChar(a, b, 0x202B);
     40    failedCount += testChar(a, b, 0x202C);
     41    failedCount += testChar(a, b, 0x202D);
     42    failedCount += testChar(a, b, 0x202E);
     43    failedCount += testChar(a, b, 0xFEFF);
     44    failedCount += testChar(a, b, 0xFFFC);
     45
     46    return failedCount;
     47}
     48
    2449function test()
    2550{
    2651    if (window.layoutTestController)
    2752        layoutTestController.dumpAsText();
    28     var failedCount = 0;
    29     for (var i = 1; i < 32; ++i)
    30         if (i != 9 && i != 10 && i != 13)
    31             failedCount += testChar(i);
    3253
    33     for (var i = 0x7F; i < 0xA0; ++i)
    34         failedCount += testChar(i);
    35     failedCount += testChar(0xAD);
    36     // ZWJ (U+200C) and ZWNJ (U+200D) are excluded because they
    37     // can affect the rendering in complex script text.
    38     failedCount += testChar(0x200B);
    39     failedCount += testChar(0x200E);
    40     failedCount += testChar(0x200F);
    41     failedCount += testChar(0x202A);
    42     failedCount += testChar(0x202B);
    43     failedCount += testChar(0x202C);
    44     failedCount += testChar(0x202D);
    45     failedCount += testChar(0x202E);
    46     failedCount += testChar(0xFEFF);
    47     failedCount += testChar(0xFFFC);
     54    var failedDevanagariCount = testWithZeroWidthSpace("\u0915\u093E", "\u0916");
     55
     56    var failedArabicCount = testWithZeroWidthSpace("\u0627\u0644\u0645\u062A\u0648\u0633\u0637\u0020\u200B\u200B\u0647\u0648\u0020\u0020", "\u0647\u0648\u0020");
    4857
    4958    var testArea = document.getElementById("testArea");
    5059    testArea.parentNode.removeChild(testArea);
    5160
    52     if (failedCount > 0)
    53         result = "FAIL: " + failedCount + " characters had non-zero width" +
    54                  " or failed to get measured.";
    55     else
     61    var result = "";
     62    if (failedDevanagariCount == 0 && failedArabicCount == 0)
    5663        result = "PASS: All characters had zero-width.";
     64    else {
     65        if (failedDevanagariCount > 0)
     66            result = "FAIL: " + failedDevanagariCount + " characters had non-zero width" +
     67                 " or failed to get measured when test with Devanagari";
     68        if (failedArabicCount > 0)
     69            result += "\nFAIL: " + failedArabicCount + " characters had non-zero width" +
     70                 " or failed to get measured when test with Arabic";
     71    }
    5772    document.getElementById("result").firstChild.data = result;
    5873}
  • trunk/Source/WebCore/ChangeLog

    r111587 r111589  
     12012-03-21  Xiaomei Ji  <xji@chromium.org>
     2
     3        [chromium] Font fallback in cr-win is wrong for string contains zero-width-space.
     4        https://bugs.webkit.org/show_bug.cgi?id=79961
     5
     6        Reviewed by Adam Barth.
     7
     8        Treat zero-width-space (\u200B) as true for treatAsZeroWidthSpaceInComplexScipt().
     9
     10        * platform/graphics/Font.h:
     11        (WebCore::Font::treatAsZeroWidthSpaceInComplexScript):
     12        * platform/graphics/mac/ComplexTextController.cpp:
     13        (WebCore::ComplexTextController::adjustGlyphsAndAdvances):
     14        * platform/graphics/win/UniscribeController.cpp:
     15        (WebCore::UniscribeController::shapeAndPlaceItem):
     16
    1172012-03-21  Patrick Gansterer  <paroga@webkit.org>
    218
  • trunk/Source/WebCore/platform/graphics/Font.h

    r104786 r111589  
    230230    static bool treatAsSpace(UChar c) { return c == ' ' || c == '\t' || c == '\n' || c == noBreakSpace; }
    231231    static bool treatAsZeroWidthSpace(UChar c) { return treatAsZeroWidthSpaceInComplexScript(c) || c == 0x200c || c == 0x200d; }
    232     static bool treatAsZeroWidthSpaceInComplexScript(UChar c) { return c < 0x20 || (c >= 0x7F && c < 0xA0) || c == softHyphen || (c >= 0x200e && c <= 0x200f) || (c >= 0x202a && c <= 0x202e) || c == zeroWidthNoBreakSpace || c == objectReplacementCharacter; }
     232    static bool treatAsZeroWidthSpaceInComplexScript(UChar c) { return c < 0x20 || (c >= 0x7F && c < 0xA0) || c == softHyphen || c == zeroWidthSpace || (c >= 0x200e && c <= 0x200f) || (c >= 0x202a && c <= 0x202e) || c == zeroWidthNoBreakSpace || c == objectReplacementCharacter; }
    233233    static bool canReceiveTextEmphasis(UChar32 c);
    234234
  • trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp

    r105866 r111589  
    520520                float tabWidth = m_font.tabWidth(*fontData);
    521521                advance.width = tabWidth - fmodf(m_run.xPos() + m_totalWidth + widthSinceLastCommit, tabWidth);
    522             } else if (ch == zeroWidthSpace || (Font::treatAsZeroWidthSpace(ch) && !treatAsSpace)) {
     522            } else if (Font::treatAsZeroWidthSpace(ch) && !treatAsSpace) {
    523523                advance.width = 0;
    524524                glyph = fontData->spaceGlyph();
  • trunk/Source/WebCore/platform/graphics/win/UniscribeController.cpp

    r105756 r111589  
    273273        UChar ch = *(str + k);
    274274        bool treatAsSpace = Font::treatAsSpace(ch);
    275         bool treatAsZeroWidthSpace = ch == zeroWidthSpace || Font::treatAsZeroWidthSpace(ch);
     275        bool treatAsZeroWidthSpace = Font::treatAsZeroWidthSpace(ch);
    276276        if (treatAsSpace || treatAsZeroWidthSpace) {
    277277            // Substitute in the space glyph at the appropriate place in the glyphs
Note: See TracChangeset for help on using the changeset viewer.