Changeset 53958 in webkit


Ignore:
Timestamp:
Jan 27, 2010 4:16:53 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-01-27 Evan Martin <evan@chromium.org>

Reviewed by David Levin.

[chromium] complex text draws newlines as bells
https://bugs.webkit.org/show_bug.cgi?id=34186

Revert r45496 -- once we've got a glyph array, it is too late to normalize
because we could have had multiple codepoints combine into one glyph. The
Uniscribe code it mentions it's duplicating uses the log cluster map to fix
this.

Instead, we just normalize the input text if it contains any non-ascii-space
whitespace.

This fixes fast/text/international/hindi-whitespace, which currently has an
incorrect baseline containing a square box glyph.

  • platform/graphics/chromium/FontLinux.cpp: (WebCore::TextRunWalker::getTextRun): (WebCore::TextRunWalker::getNormalizedTextRun):
  • platform/graphics/chromium/HarfbuzzSkia.cpp: (WebCore::stringToGlyphs):
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r53957 r53958  
     12010-01-27  Evan Martin  <evan@chromium.org>
     2
     3        Reviewed by David Levin.
     4
     5        [chromium] complex text draws newlines as bells
     6        https://bugs.webkit.org/show_bug.cgi?id=34186
     7
     8        Revert r45496 -- once we've got a glyph array, it is too late to normalize
     9        because we could have had multiple codepoints combine into one glyph.  The
     10        Uniscribe code it mentions it's duplicating uses the log cluster map to fix
     11        this.
     12
     13        Instead, we just normalize the input text if it contains any non-ascii-space
     14        whitespace.
     15
     16        This fixes fast/text/international/hindi-whitespace, which currently has an
     17        incorrect baseline containing a square box glyph.
     18
     19        * platform/graphics/chromium/FontLinux.cpp:
     20        (WebCore::TextRunWalker::getTextRun):
     21        (WebCore::TextRunWalker::getNormalizedTextRun):
     22        * platform/graphics/chromium/HarfbuzzSkia.cpp:
     23        (WebCore::stringToGlyphs):
     24
    1252010-01-27  Alexey Proskuryakov  <ap@apple.com>
    226
  • trunk/WebCore/platform/graphics/chromium/FontLinux.cpp

    r49994 r53958  
    313313    const TextRun& getTextRun(const TextRun& originalRun)
    314314    {
    315         // Convert the |originalRun| to NFC normalized form if combining diacritical marks
     315        // Normalize the text run in two ways:
     316        // 1) Convert the |originalRun| to NFC normalized form if combining diacritical marks
    316317        // (U+0300..) are used in the run. This conversion is necessary since most OpenType
    317318        // fonts (e.g., Arial) don't have substitution rules for the diacritical marks in
     
    322323        // normalization (e.g., Arabic text). Unless the run contains the diacritical marks,
    323324        // Harfbuzz will do the same thing for us using the GSUB table.
     325        // 2) Convert spacing characters into plain spaces, as some fonts will provide glyphs
     326        // for characters like '\n' otherwise.
    324327        for (unsigned i = 0; i < originalRun.length(); ++i) {
    325             UBlockCode block = ::ublock_getCode(originalRun[i]);
    326             if (block == UBLOCK_COMBINING_DIACRITICAL_MARKS) {
     328            UChar ch = originalRun[i];
     329            UBlockCode block = ::ublock_getCode(ch);
     330            if (block == UBLOCK_COMBINING_DIACRITICAL_MARKS || (Font::treatAsSpace(ch) && ch != ' ')) {
    327331                return getNormalizedTextRun(originalRun);
    328332            }
     
    342346        normalizedString.extract(m_normalizedBuffer.get(), normalizedString.length() + 1, error);
    343347        ASSERT(U_SUCCESS(error));
     348
     349        for (unsigned i = 0; i < normalizedString.length(); ++i) {
     350            if (Font::treatAsSpace(m_normalizedBuffer[i]))
     351                m_normalizedBuffer[i] = ' ';
     352        }
    344353
    345354        m_normalizedRun.set(new TextRun(originalRun));
  • trunk/WebCore/platform/graphics/chromium/HarfbuzzSkia.cpp

    r45496 r53958  
    3131#include "config.h"
    3232
    33 #include "Font.h"
    3433#include "FontPlatformData.h"
    3534#include "wtf/OwnArrayPtr.h"
     
    4342extern "C" {
    4443#include "harfbuzz-shaper.h"
    45 #include "harfbuzz-unicode.h"
    4644}
    4745
     
    6866    // HB_Glyph is 32-bit, but Skia outputs only 16-bit numbers. So our
    6967    // |glyphs| array needs to be converted.
    70     // Additionally, if the CSS white-space property is inhibiting line
    71     // breaking, we might find end-of-line charactors rendered via the complex
    72     // text path. Fonts don't provide glyphs for these code points so, if we
    73     // find one, we simulate the space glyph being interposed in this case.
    74     // Because the input is variable-length per code point, we walk the input
    75     // in step with the output.
    76     // FIXME: it seems that this logic is duplicated in CoreTextController and UniscribeController
    77     ssize_t indexOfNextCodePoint = 0;
    78     uint16_t spaceGlyphNumber = 0;
    7968    for (int i = numGlyphs - 1; i >= 0; --i) {
    80         const uint32_t currentCodePoint = utf16_to_code_point(characters, length, &indexOfNextCodePoint);
    81 
    8269        uint16_t value;
    8370        // We use a memcpy to avoid breaking strict aliasing rules.
    8471        memcpy(&value, reinterpret_cast<char*>(glyphs) + sizeof(uint16_t) * i, sizeof(uint16_t));
    85 
    86         if (!value && Font::treatAsSpace(currentCodePoint)) {
    87             static const uint16_t spaceUTF16 = ' ';
    88             if (!spaceGlyphNumber)
    89                 paint.textToGlyphs(&spaceUTF16, sizeof(spaceUTF16), &spaceGlyphNumber);
    90             value = spaceGlyphNumber;
    91         }
    92 
    9372        glyphs[i] = value;
    9473    }
Note: See TracChangeset for help on using the changeset viewer.