Changeset 245094 in webkit


Ignore:
Timestamp:
May 8, 2019 11:06:27 PM (5 years ago)
Author:
Carlos Garcia Campos
Message:

REGRESSION(r239915): [FreeType] White space skipped when rendering plain text with noto CJK font
https://bugs.webkit.org/show_bug.cgi?id=197658

Reviewed by Michael Catanzaro.

Since r239915 we no longer overwrite control characters with zero width space, they are handled later when
filling the glyph pages. In Font::platformGlyphInit() there's an optimization to get the glyph of zero with
space character that assumes that control characters are always overwritten. Since the glyph for character at 0
index is always overwritten with zero width space, we can avoid loading the page for the actual zero width space
character and use the first page instead. In the particular case of noto CJK font, character at 0 is mapped to
the same glyph as space character, so space and zero width space end up being the same glyph. That breaks the
space width calculation, that returns 0 when isZeroWidthSpaceGlyph() is true. That's why spaces are no
longer rendered, ComplexTextController::adjustGlyphsAndAdvances() is setting the x advance for the space glyphs
to 0.

  • platform/graphics/Font.cpp:

(WebCore::Font::platformGlyphInit): Use the actual zero width space page to get the glyph instead of 0 when
using FreeType.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r245090 r245094  
     12019-05-08  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        REGRESSION(r239915): [FreeType] White space skipped when rendering plain text with noto CJK font
     4        https://bugs.webkit.org/show_bug.cgi?id=197658
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        Since r239915 we no longer overwrite control characters with zero width space, they are handled later when
     9        filling the glyph pages. In Font::platformGlyphInit() there's an optimization to get the glyph of zero with
     10        space character that assumes that control characters are always overwritten. Since the glyph for character at 0
     11        index is always overwritten with zero width space, we can avoid loading the page for the actual zero width space
     12        character and use the first page instead. In the particular case of noto CJK font, character at 0 is mapped to
     13        the same glyph as space character, so space and zero width space end up being the same glyph. That breaks the
     14        space width calculation, that returns 0 when isZeroWidthSpaceGlyph() is true. That's why spaces are no
     15        longer rendered, ComplexTextController::adjustGlyphsAndAdvances() is setting the x advance for the space glyphs
     16        to 0.
     17
     18        * platform/graphics/Font.cpp:
     19        (WebCore::Font::platformGlyphInit): Use the actual zero width space page to get the glyph instead of 0 when
     20        using FreeType.
     21
    1222019-05-08  Alex Christensen  <achristensen@webkit.org>
    223
  • trunk/Source/WebCore/platform/graphics/Font.cpp

    r243163 r245094  
    103103void Font::platformGlyphInit()
    104104{
    105     auto* glyphPageZero = glyphPage(0);
     105#if USE(FREETYPE)
     106    auto* glyphPageZeroWidthSpace = glyphPage(GlyphPage::pageNumberForCodePoint(zeroWidthSpace));
     107    UChar32 zeroWidthSpaceCharacter = zeroWidthSpace;
     108#else
     109    // Ask for the glyph for 0 to avoid paging in ZERO WIDTH SPACE. Control characters, including 0,
     110    // are mapped to the ZERO WIDTH SPACE glyph for non FreeType based ports.
     111    auto* glyphPageZeroWidthSpace = glyphPage(0);
     112    UChar32 zeroWidthSpaceCharacter = 0;
     113#endif
    106114    auto* glyphPageCharacterZero = glyphPage(GlyphPage::pageNumberForCodePoint('0'));
    107115    auto* glyphPageSpace = glyphPage(GlyphPage::pageNumberForCodePoint(space));
    108116
    109     // Ask for the glyph for 0 to avoid paging in ZERO WIDTH SPACE. Control characters, including 0,
    110     // are mapped to the ZERO WIDTH SPACE glyph.
    111     if (glyphPageZero)
    112         m_zeroWidthSpaceGlyph = glyphPageZero->glyphDataForCharacter(0).glyph;
     117    if (glyphPageZeroWidthSpace)
     118        m_zeroWidthSpaceGlyph = glyphPageZeroWidthSpace->glyphDataForCharacter(zeroWidthSpaceCharacter).glyph;
    113119
    114120    // Nasty hack to determine if we should round or ceil space widths.
Note: See TracChangeset for help on using the changeset viewer.