Changeset 84989 in webkit


Ignore:
Timestamp:
Apr 26, 2011 5:17:41 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-04-26 Chun-Lung Huang <alvincl.huang@gmail.com>

Reviewed by Adele Peterson.

On WebKit (Windows), glyphs in vertical text tests are rotated 90
degrees clockwise. https://bugs.webkit.org/show_bug.cgi?id=48459

This platform dependent patch makes WebKit (Windows) show the
vertical writing text correctly. Job was done by adding a prefix '@'
in front of the font family name (Windows Only). No new tests added.
Some layout tests images:
http://www.flickr.com/photos/burorly/sets/72157625585506341/

  • platform/graphics/FontPlatformData.h:
  • platform/graphics/win/FontCacheWin.cpp: (WebCore::FontCache::getFontDataForCharacters): (WebCore::FontCache::createFontPlatformData):
  • platform/graphics/win/FontCustomPlatformData.cpp: (WebCore::FontCustomPlatformData::fontPlatformData):
  • platform/graphics/win/FontPlatformDataCGWin.cpp: (WebCore::FontPlatformData::FontPlatformData):
  • platform/graphics/win/FontPlatformDataWin.cpp: (WebCore::FontPlatformData::FontPlatformData):
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r84988 r84989  
     12011-04-26  Chun-Lung Huang  <alvincl.huang@gmail.com>
     2
     3        Reviewed by Adele Peterson.
     4
     5        On WebKit (Windows), glyphs in vertical text tests are rotated 90
     6        degrees clockwise.  https://bugs.webkit.org/show_bug.cgi?id=48459
     7
     8        This platform dependent patch makes WebKit (Windows) show the
     9        vertical writing text correctly.  Job was done by adding a prefix '@'
     10        in front of the font family name (Windows Only). No new tests added.
     11        Some layout tests images:
     12        http://www.flickr.com/photos/burorly/sets/72157625585506341/
     13
     14        * platform/graphics/FontPlatformData.h:
     15        * platform/graphics/win/FontCacheWin.cpp:
     16        (WebCore::FontCache::getFontDataForCharacters):
     17        (WebCore::FontCache::createFontPlatformData):
     18        * platform/graphics/win/FontCustomPlatformData.cpp:
     19        (WebCore::FontCustomPlatformData::fontPlatformData):
     20        * platform/graphics/win/FontPlatformDataCGWin.cpp:
     21        (WebCore::FontPlatformData::FontPlatformData):
     22        * platform/graphics/win/FontPlatformDataWin.cpp:
     23        (WebCore::FontPlatformData::FontPlatformData):
     24
    1252011-04-26  Jer Noble  <jer.noble@apple.com>
    226
  • trunk/Source/WebCore/platform/graphics/FontPlatformData.h

    r84101 r84989  
    197197#endif
    198198#if PLATFORM(WIN)
    199     FontPlatformData(HFONT, float size, bool syntheticBold, bool syntheticOblique, bool useGDI);
     199    FontPlatformData(HFONT, float size, bool syntheticBold, bool syntheticOblique, bool useGDI, FontOrientation = Horizontal);
    200200#if USE(CG)
    201     FontPlatformData(HFONT, CGFontRef, float size, bool syntheticBold, bool syntheticOblique, bool useGDI);
     201    FontPlatformData(HFONT, CGFontRef, float size, bool syntheticBold, bool syntheticOblique, bool useGDI, FontOrientation = Horizontal);
    202202#endif
    203203#endif
  • trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp

    r84101 r84989  
    284284    if (hfont) {
    285285        if (!familyName.isEmpty()) {
    286             FontPlatformData* result = getCachedFontPlatformData(font.fontDescription(), familyName);
     286            FontPlatformData* result;
     287            // Take the orientation into consideration. For vertical: add "@" in front of the family name.
     288            // "@" is a built-in behaviour for Windows platform. http://msdn.microsoft.com/en-us/goglobal/bb688137
     289            if (font.fontDescription().orientation() == Vertical && !familyName.startsWith("@"))
     290                result = getCachedFontPlatformData(font.fontDescription(), "@" + String(familyName));
     291            else
     292                result = getCachedFontPlatformData(font.fontDescription(), familyName);
     293           
    287294            if (result)
    288295                fontData = getCachedFontData(result);
     
    560567    bool useGDI = fontDescription.renderingMode() == AlternateRenderingMode && !isLucidaGrande;
    561568
     569    // Take the orientation into consideration. For vertical: add "@" in front of the family name.
     570    // "@" is a built-in behaviour for Windows platform. http://msdn.microsoft.com/en-us/goglobal/bb688137
     571    AtomicString updatedFamilyName;
     572    if (fontDescription.orientation() == Vertical && !family.startsWith("@"))
     573        updatedFamilyName = "@" + String(family);
     574    else
     575        updatedFamilyName = family;
     576
    562577    // The logical size constant is 32. We do this for subpixel precision when rendering using Uniscribe.
    563578    // This masks rounding errors related to the HFONT metrics being  different from the CGFont metrics.
    564579    // FIXME: We will eventually want subpixel precision for GDI mode, but the scaled rendering doesn't
    565580    // look as nice. That may be solvable though.
    566     LONG weight = adjustedGDIFontWeight(toGDIFontWeight(fontDescription.weight()), family);
    567     HFONT hfont = createGDIFont(family, weight, fontDescription.italic(),
     581    LONG weight = adjustedGDIFontWeight(toGDIFontWeight(fontDescription.weight()), updatedFamilyName);
     582    HFONT hfont = createGDIFont(updatedFamilyName, weight, fontDescription.italic(),
    568583                                fontDescription.computedPixelSize() * (useGDI ? 1 : 32), useGDI);
     584
     585    // Some fonts do not need to be rotated when displayed vertically.
     586    // Or "@font-family-name" is not supported on user's platform.
     587    // (e.g. no "@Times New Romain" or "@Arial"). Try to create hfont with original family name.
     588    if (updatedFamilyName.startsWith("@") && !hfont) {
     589        weight = adjustedGDIFontWeight(toGDIFontWeight(fontDescription.weight()), family);
     590        hfont = createGDIFont(family, weight, fontDescription.italic(),
     591        fontDescription.computedPixelSize() * (useGDI ? 1 : 32), useGDI);
     592    }
    569593
    570594    if (!hfont)
     
    580604    bool synthesizeItalic = fontDescription.italic() && !logFont.lfItalic;
    581605
    582     FontPlatformData* result = new FontPlatformData(hfont, fontDescription.computedPixelSize(), synthesizeBold, synthesizeItalic, useGDI);
     606    FontPlatformData* result = new FontPlatformData(hfont, fontDescription.computedPixelSize(), synthesizeBold, synthesizeItalic, useGDI, fontDescription.orientation());
    583607
    584608#if USE(CG)
  • trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp

    r80582 r84989  
    6060}
    6161
    62 FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation, TextOrientation, FontWidthVariant, FontRenderingMode renderingMode)
     62FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, bool italic, FontOrientation orientation, TextOrientation, FontWidthVariant, FontRenderingMode renderingMode)
    6363{
    6464    ASSERT(m_fontReference);
     
    6666
    6767    LOGFONT& logFont = *static_cast<LOGFONT*>(malloc(sizeof(LOGFONT)));
    68     if (m_name.isNull())
     68    if (m_name.isNull()) {
    6969        TTGetNewFontName(&m_fontReference, logFont.lfFaceName, LF_FACESIZE, 0, 0);
     70        m_name = logFont.lfFaceName;
     71    }
     72
     73    // Take the orientation into consideration. For vertical: add "@" in front of the family name. (Windows)
     74    String newName;
     75    if (orientation == Vertical && !m_name.startsWith("@"))
     76        newName = "@" + m_name;
    7077    else
    71         memcpy(logFont.lfFaceName, m_name.charactersWithNullTermination(), sizeof(logFont.lfFaceName[0]) * min(static_cast<size_t>(LF_FACESIZE), 1 + m_name.length()));
     78        newName = m_name;
     79    memcpy(logFont.lfFaceName, newName.charactersWithNullTermination(), sizeof(logFont.lfFaceName[0]) * min(static_cast<size_t>(LF_FACESIZE), 1 + newName.length()));
    7280
    7381    logFont.lfHeight = -size;
     
    8997
    9098    RetainPtr<CGFontRef> cgFont(AdoptCF, CGFontCreateWithPlatformFont(&logFont));
    91     return FontPlatformData(hfont, cgFont.get(), size, bold, italic, renderingMode == AlternateRenderingMode);
     99    return FontPlatformData(hfont, cgFont.get(), size, bold, italic, renderingMode == AlternateRenderingMode, orientation);
    92100}
    93101
  • trunk/Source/WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp

    r81977 r84989  
    115115}
    116116
    117 FontPlatformData::FontPlatformData(HFONT hfont, CGFontRef font, float size, bool bold, bool oblique, bool useGDI)
     117FontPlatformData::FontPlatformData(HFONT hfont, CGFontRef font, float size, bool bold, bool oblique, bool useGDI, FontOrientation orientation)
    118118    : m_syntheticBold(bold)
    119119    , m_syntheticOblique(oblique)
    120     , m_orientation(Horizontal)
     120    , m_orientation(orientation)
    121121    , m_textOrientation(TextOrientationVerticalRight)
    122122    , m_size(size)
  • trunk/Source/WebCore/platform/graphics/win/FontPlatformDataWin.cpp

    r84101 r84989  
    3636namespace WebCore {
    3737
    38 FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool oblique, bool useGDI)
     38FontPlatformData::FontPlatformData(HFONT font, float size, bool bold, bool oblique, bool useGDI, FontOrientation orientation)
    3939    : m_font(RefCountedGDIHandle<HFONT>::create(font))
    4040    , m_size(size)
    41     , m_orientation(Horizontal)
     41    , m_orientation(orientation)
    4242    , m_textOrientation(TextOrientationVerticalRight)
    4343    , m_widthVariant(RegularWidth)
Note: See TracChangeset for help on using the changeset viewer.