Changeset 76679 in webkit


Ignore:
Timestamp:
Jan 26, 2011 2:12:50 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-01-26 Hironori Bono <hbono@chromium.org>

Reviewed by Kent Tamura.

A speculative fix for Bug 52422 - [chromium] More crash in
FontFallbackList::determinePitch(const Font* font)
https://bugs.webkit.org/show_bug.cgi?id=52422

My previous change may not work on non-US Windows whose system fonts
have localized aliases matching to the system locale because of a
font-name mismatch in createFontIndirectAndGetWinName(). This change
tries all the fonts installed in a PC and returns the first font that we
can create without errors.

  • platform/graphics/chromium/FontCacheChromiumWin.cpp: (WebCore::GetLastResortFallbackFontProcData::GetLastResortFallbackFontProcData): Added a struct used for getLastResortFallbackFontProc(). (WebCore::getLastResortFallbackFontProc): Added a callback for EnumFontFamilies(). (WebCore::FontCache::getLastResortFallbackFont): Use EnumFontFamilies() to find a last-resort font.
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r76677 r76679  
     12011-01-26  Hironori Bono  <hbono@chromium.org>
     2
     3        Reviewed by Kent Tamura.
     4
     5        A speculative fix for Bug 52422 - [chromium] More crash in
     6        FontFallbackList::determinePitch(const Font* font)
     7        https://bugs.webkit.org/show_bug.cgi?id=52422
     8
     9        My previous change may not work on non-US Windows whose system fonts
     10        have localized aliases matching to the system locale because of a
     11        font-name mismatch in createFontIndirectAndGetWinName(). This change
     12        tries all the fonts installed in a PC and returns the first font that we
     13        can create without errors.
     14
     15        * platform/graphics/chromium/FontCacheChromiumWin.cpp:
     16        (WebCore::GetLastResortFallbackFontProcData::GetLastResortFallbackFontProcData):
     17        Added a struct used for getLastResortFallbackFontProc().
     18        (WebCore::getLastResortFallbackFontProc): Added a callback for EnumFontFamilies().
     19        (WebCore::FontCache::getLastResortFallbackFont): Use EnumFontFamilies() to find a last-resort font.
     20
    1212011-01-26  James Robinson  <jamesr@chromium.org>
    222
  • trunk/Source/WebCore/platform/graphics/chromium/FontCacheChromiumWin.cpp

    r76340 r76679  
    400400}
    401401
     402struct GetLastResortFallbackFontProcData {
     403    GetLastResortFallbackFontProcData(FontCache* fontCache, const FontDescription* fontDescription, wchar_t* fontName)
     404        : m_fontCache(fontCache)
     405        , m_fontDescription(fontDescription)
     406        , m_fontName(fontName)
     407        , m_fontData(0)
     408    {
     409    }
     410
     411    FontCache* m_fontCache;
     412    const FontDescription* m_fontDescription;
     413    wchar_t* m_fontName;
     414    SimpleFontData* m_fontData;
     415};
     416
     417static int CALLBACK getLastResortFallbackFontProc(const LOGFONT* logFont, const TEXTMETRIC* metrics, DWORD fontType, LPARAM lParam)
     418{
     419    GetLastResortFallbackFontProcData* procData = reinterpret_cast<GetLastResortFallbackFontProcData*>(lParam);
     420    procData->m_fontData = fontDataFromDescriptionAndLogFont(procData->m_fontCache, *procData->m_fontDescription, *logFont, procData->m_fontName);
     421    return !procData->m_fontData;
     422}
     423
    402424void FontCache::platformInit()
    403425{
     
    549571    }
    550572
     573    // Fall back to all the fonts installed in this PC. When a font has a
     574    // localized name according to the system locale as well as an English name,
     575    // both GetTextFace() and EnumFontFamilies() return the localized name. So,
     576    // FontCache::createFontPlatformData() does not filter out the fonts
     577    // returned by this EnumFontFamilies() call.
     578    HDC dc = GetDC(0);
     579    if (dc) {
     580        GetLastResortFallbackFontProcData procData(this, &description, fallbackFontName);
     581        EnumFontFamilies(dc, 0, getLastResortFallbackFontProc, reinterpret_cast<LPARAM>(&procData));
     582        ReleaseDC(0, dc);
     583
     584        if (procData.m_fontData)
     585            return procData.m_fontData;
     586    }
     587
    551588    ASSERT_NOT_REACHED();
    552589    return 0;
Note: See TracChangeset for help on using the changeset viewer.