Changeset 102915 in webkit


Ignore:
Timestamp:
Dec 15, 2011 3:57:05 AM (12 years ago)
Author:
bashi@chromium.org
Message:

Supports Unicode variation selector
https://bugs.webkit.org/show_bug.cgi?id=50999

Reviewed by Nikolas Zimmermann.

Source/WebCore:

Adds SimpleFontData::updateGlyphWithVariationSelector() which substitutes the
glyph in question based on the selector. WidthIterator::advance() calls it
when an unicode variation selector follows the character.

Test: fast/text/unicode-variation-selector.html

  • platform/graphics/SimpleFontData.h: Added updateGlyphWithVariationSelector().
  • platform/graphics/SurrogatePairAwareTextIterator.cpp:

(WebCore::isUnicodeBMPVariationSelector): Added.
(WebCore::isUnicodeSupplementaryVariationSelector): Added.
(WebCore::SurrogatePairAwareTextIterator::hasTrailingVariationSelector): Added.

  • platform/graphics/SurrogatePairAwareTextIterator.h:
  • platform/graphics/WidthIterator.cpp:

(WebCore::WidthIterator::advance): Changed to detect variation selectors.

  • platform/graphics/chromium/SimpleFontDataChromiumWin.cpp:

(WebCore::SimpleFontData::updateGlyphWithVariationSelector): Added.

  • platform/graphics/chromium/SimpleFontDataLinux.cpp:

(WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.

  • platform/graphics/freetype/SimpleFontDataFreeType.cpp:

(WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.

  • platform/graphics/mac/SimpleFontDataMac.mm:

(WebCore::decomposeToUTF16): Ditto.
(WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.

  • platform/graphics/pango/SimpleFontDataPango.cpp:

(WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.

  • platform/graphics/qt/SimpleFontDataQt.cpp:

(WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.

  • platform/graphics/win/SimpleFontDataWin.cpp:

(WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.

  • platform/graphics/wince/SimpleFontDataWinCE.cpp:

(WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.

  • platform/graphics/wx/SimpleFontDataWx.cpp:

(WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.

LayoutTests:

Add test for unicode variation selector support.
A tiny font (gw432047.ttf), which comes from glyphwiki.org and is used by Mozilla, is added for the test.

  • fast/text/resources/gw432047-license.txt: Added.
  • fast/text/resources/gw432047.ttf: Added.
  • fast/text/unicode-variation-selector.html: Added.
  • platform/chromium/test_expectations.txt: Added fast/text/unicode-variation-selector.html. This test need rebaseline.
Location:
trunk
Files:
3 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    • Property svn:executable deleted
    r102913 r102915  
     12011-12-15  Kenichi Ishibashi  <bashi@chromium.org>
     2
     3        Supports Unicode variation selector
     4        https://bugs.webkit.org/show_bug.cgi?id=50999
     5
     6        Reviewed by Nikolas Zimmermann.
     7
     8        Add test for unicode variation selector support.
     9        A tiny font (gw432047.ttf), which comes from glyphwiki.org and is used by Mozilla, is added for the test.
     10
     11        * fast/text/resources/gw432047-license.txt: Added.
     12        * fast/text/resources/gw432047.ttf: Added.
     13        * fast/text/unicode-variation-selector.html: Added.
     14        * platform/chromium/test_expectations.txt: Added fast/text/unicode-variation-selector.html. This test need rebaseline.
     15
    1162011-12-15  Alexander Pavlov  <apavlov@chromium.org>
    217
  • trunk/LayoutTests/platform/chromium/test_expectations.txt

    r102896 r102915  
    40084008
    40094009BUGWK74555 : fast/images/move-image-to-new-document.html = TEXT TIMEOUT
     4010
     4011// Need rebaseline on Mac.
     4012BUGWK50999 : fast/text/unicode-variation-selector.html = MISSING FAIL
  • trunk/Source/WebCore/ChangeLog

    • Property svn:executable deleted
    r102913 r102915  
     12011-12-15  Kenichi Ishibashi  <bashi@chromium.org>
     2
     3        Supports Unicode variation selector
     4        https://bugs.webkit.org/show_bug.cgi?id=50999
     5
     6        Reviewed by Nikolas Zimmermann.
     7
     8        Adds SimpleFontData::updateGlyphWithVariationSelector() which substitutes the
     9        glyph in question based on the selector. WidthIterator::advance() calls it
     10        when an unicode variation selector follows the character.
     11
     12        Test: fast/text/unicode-variation-selector.html
     13
     14        * platform/graphics/SimpleFontData.h: Added updateGlyphWithVariationSelector().
     15        * platform/graphics/SurrogatePairAwareTextIterator.cpp:
     16        (WebCore::isUnicodeBMPVariationSelector): Added.
     17        (WebCore::isUnicodeSupplementaryVariationSelector): Added.
     18        (WebCore::SurrogatePairAwareTextIterator::hasTrailingVariationSelector): Added.
     19        * platform/graphics/SurrogatePairAwareTextIterator.h:
     20        * platform/graphics/WidthIterator.cpp:
     21        (WebCore::WidthIterator::advance): Changed to detect variation selectors.
     22        * platform/graphics/chromium/SimpleFontDataChromiumWin.cpp:
     23        (WebCore::SimpleFontData::updateGlyphWithVariationSelector): Added.
     24        * platform/graphics/chromium/SimpleFontDataLinux.cpp:
     25        (WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.
     26        * platform/graphics/freetype/SimpleFontDataFreeType.cpp:
     27        (WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.
     28        * platform/graphics/mac/SimpleFontDataMac.mm:
     29        (WebCore::decomposeToUTF16): Ditto.
     30        (WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.
     31        * platform/graphics/pango/SimpleFontDataPango.cpp:
     32        (WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.
     33        * platform/graphics/qt/SimpleFontDataQt.cpp:
     34        (WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.
     35        * platform/graphics/win/SimpleFontDataWin.cpp:
     36        (WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.
     37        * platform/graphics/wince/SimpleFontDataWinCE.cpp:
     38        (WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.
     39        * platform/graphics/wx/SimpleFontDataWx.cpp:
     40        (WebCore::SimpleFontData::updateGlyphWithVariationSelector): Ditto.
     41
    1422011-12-15  Alexander Pavlov  <apavlov@chromium.org>
    243
  • trunk/Source/WebCore/platform/graphics/SimpleFontData.h

    r101554 r102915  
    159159    const GlyphData& missingGlyphData() const { return m_missingGlyphData; }
    160160    void setMissingGlyphData(const GlyphData& glyphData) { m_missingGlyphData = glyphData; }
     161    void updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph&) const;
    161162
    162163#ifndef NDEBUG
  • trunk/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.cpp

    r89690 r102915  
    3232
    3333namespace WebCore {
     34
     35inline static bool isUnicodeBMPVariationSelector(UChar character)
     36{
     37    return (0x180B <= character && character <= 0x180D) || (0xFE00 <= character && character <= 0xFE0F);
     38}
     39
     40inline static bool isUnicodeSupplementaryVariationSelector(UChar lead, UChar trail)
     41{
     42    // A non-BMP variation selector character is in the range of U+E0100 to U+E01EF.
     43    // It can be a surrogate pair in which the high surrogate is 0xDB40 and
     44    // the low surrogate is in the range of U16_TRAIL(0xE0100 - 0x10000) to U16_TRAIL(0xE01EF - 0x10000).
     45    static const UChar trailStart = U16_TRAIL(0xE0100 - 0x10000);
     46    static const UChar trailEnd = U16_TRAIL(0xE01EF - 0x10000);
     47    return lead == 0xDB40 && trailStart <= trail && trail <= trailEnd;
     48}
    3449
    3550SurrogatePairAwareTextIterator::SurrogatePairAwareTextIterator(const UChar* characters, int currentCharacter, int lastCharacter, int endCharacter)
     
    8499}
    85100
     101bool SurrogatePairAwareTextIterator::hasTrailingVariationSelector(UChar32& selector, unsigned& clusterLength)
     102{
     103    if (static_cast<int>(m_currentCharacter + clusterLength) < m_endCharacter && isUnicodeBMPVariationSelector(m_characters[clusterLength])) {
     104        selector = m_characters[clusterLength];
     105        clusterLength += 1;
     106        return true;
     107    }
     108    if (static_cast<int>(m_currentCharacter + clusterLength + 1) < m_endCharacter && isUnicodeSupplementaryVariationSelector(m_characters[clusterLength], m_characters[clusterLength + 1])) {
     109        selector = U16_GET_SUPPLEMENTARY(m_characters[clusterLength], m_characters[clusterLength + 1]);
     110        clusterLength += 2;
     111        return true;
     112    }
     113    return false;
     114}
     115
    86116void SurrogatePairAwareTextIterator::advance(unsigned advanceLength)
    87117{
  • trunk/Source/WebCore/platform/graphics/SurrogatePairAwareTextIterator.h

    r95901 r102915  
    3333
    3434    bool consume(UChar32& character, unsigned& clusterLength);
     35    bool hasTrailingVariationSelector(UChar32& selector, unsigned& clusterLength);
    3536    void advance(unsigned advanceLength);
    3637
  • trunk/Source/WebCore/platform/graphics/WidthIterator.cpp

    r90798 r102915  
    115115
    116116        ASSERT(fontData);
     117
     118        // If a variation selector follows, update glyph with the selector if possible.
     119        UChar32 selector = 0;
     120        if (textIterator.hasTrailingVariationSelector(selector, clusterLength)) {
     121            fontData->updateGlyphWithVariationSelector(character, selector, glyph);
     122            advanceLength = clusterLength;
     123        }
    117124
    118125        // Now that we have a glyph and font data, get its width.
  • trunk/Source/WebCore/platform/graphics/chromium/SimpleFontDataChromiumWin.cpp

    r95901 r102915  
    200200}
    201201
     202void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
     203{
     204    // FIXME: Implement.
     205}
     206
    202207}  // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/chromium/SimpleFontDataLinux.cpp

    r95901 r102915  
    238238}
    239239
     240void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
     241{
     242    // FIXME: Implement.
     243}
     244
    240245}  // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp

    r101343 r102915  
    163163}
    164164
     165void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
     166{
     167    // FIXME: Implement.
    165168}
     169
     170}
  • trunk/Source/WebCore/platform/graphics/mac/SimpleFontDataMac.mm

    r98774 r102915  
    468468}
    469469
     470static inline void decomposeToUTF16(UChar* buffer, unsigned& length, const UChar32 character)
     471{
     472    if (U_IS_BMP(character)) {
     473        buffer[length] = character;
     474        ++length;
     475        return;
     476    }
     477
     478    buffer[length] = U16_LEAD(character);
     479    buffer[length + 1] = U16_TRAIL(character);
     480    length += 2;
     481}
     482
     483void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
     484{
     485    unsigned length = 0;
     486    UChar buffer[4];
     487
     488    decomposeToUTF16(buffer, length, character);
     489    decomposeToUTF16(buffer, length, selector);
     490    ASSERT(length <= 4);
     491
     492    CGGlyph glyphs[4];
     493    wkGetGlyphsForCharacters(platformData().cgFont(), buffer, glyphs, length);
     494    if (glyphs[0])
     495        glyph = glyphs[0];
     496}
     497
    470498} // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/pango/SimpleFontDataPango.cpp

    r95901 r102915  
    161161}
    162162
     163void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
     164{
     165    // FIXME: Implement.
    163166}
     167
     168}
  • trunk/Source/WebCore/platform/graphics/qt/SimpleFontDataQt.cpp

    r89733 r102915  
    190190}
    191191
     192void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
     193{
     194    // FIXME: Implement.
    192195}
     196
     197}
  • trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp

    r101554 r102915  
    283283}
    284284
    285 }
     285void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
     286{
     287    // FIXME: Implement.
     288}
     289
     290}
  • trunk/Source/WebCore/platform/graphics/wince/SimpleFontDataWinCE.cpp

    r95901 r102915  
    181181}
    182182
     183void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
     184{
     185    // FIXME: Implement.
     186}
     187
    183188} // namespace WebCore
  • trunk/Source/WebCore/platform/graphics/wx/SimpleFontDataWx.cpp

    r86401 r102915  
    195195#endif
    196196
    197 }
     197void SimpleFontData::updateGlyphWithVariationSelector(UChar32 character, UChar32 selector, Glyph& glyph) const
     198{
     199    // FIXME: Implement.
     200}
     201
     202}
Note: See TracChangeset for help on using the changeset viewer.