Source/platform/fonts/win/FontCacheSkiaWin.cpp
// Given the desired base font, this will create a SimpleFontData for a specific
// font that can be used to render the given range of characters.
Given the desired base font, this will create a SimpleFontData for a specific
font that can be used to render the given range of characters.
Given the desired base font this will create a SimpleFontData for a specific font that can be used to render the given range of characters .
PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescription& fontDescription, UChar32 character, const SimpleFontData*)
{
    UScriptCode script;
    const wchar_t* family = getFallbackFamily(character,
        fontDescription.genericFamily(),
        &script,
        m_fontManager.get());
    FontPlatformData* data = 0;
    if (family)
        data = getFontPlatformData(fontDescription,  AtomicString(family, wcslen(family)));
    const static wchar_t* const cjkFonts[] = {
        L"arial unicode ms",
        L"ms pgothic",
        L"simsun",
        L"gulim",
        L"pmingliu",
        L"wenquanyi zen hei", 
        L"ar pl shanheisun uni",
        L"ar pl zenkai uni",
        L"han nom a", 
        L"code2000" 
    };
    const static wchar_t* const commonFonts[] = {
        L"tahoma",
        L"arial unicode ms",
        L"lucida sans unicode",
        L"microsoft sans serif",
        L"palatino linotype",
        L"dejavu serif",
        L"dejavu sasns",
        L"freeserif",
        L"freesans",
        L"gentium",
        L"gentiumalt",
        L"ms pgothic",
        L"simsun",
        L"gulim",
        L"pmingliu",
        L"code2000"
    };
    const wchar_t* const* panUniFonts = 0;
    int numFonts = 0;
    if (script == USCRIPT_HAN) {
        panUniFonts = cjkFonts;
        numFonts = WTF_ARRAY_LENGTH(cjkFonts);
    } else {
        panUniFonts = commonFonts;
        numFonts = WTF_ARRAY_LENGTH(commonFonts);
    }
    int i;
    for (i = 0; (!data || !fontContainsCharacter(data, family, character)) && i < numFonts; ++i) {
        family = panUniFonts[i];
        data = getFontPlatformData(fontDescription, AtomicString(family, wcslen(family)));
    }
    if (i <= numFonts)
        return fontDataFromFontPlatformData(data, DoNotRetain);
    return nullptr;
}
PassRefPtr < SimpleFontData > FontCache :: fallbackFontForCharacter ( const FontDescription & fontDescription , UChar32 character , const SimpleFontData * ) { UScriptCode script ; const wchar_t * family = getFallbackFamily ( character , fontDescription . genericFamily ( ) , & script , m_fontManager . get ( ) ) ; FontPlatformData * data = 0 ; if ( family ) data = getFontPlatformData ( fontDescription , AtomicString ( family , wcslen ( family ) ) ) ; const static wchar_t * const cjkFonts [ ] = { L" " , L" " , L" " , L" " , L" " , L" " , L" " , L" " , L" " , L" " } ; const static wchar_t * const commonFonts [ ] = { L" " , L" " , L" " , L" " , L" " , L" " , L" " , L" " , L" " , L" " , L" " , L" " , L" " , L" " , L" " , L" " } ; const wchar_t * const * panUniFonts = 0 ; int numFonts = 0 ; if ( script == USCRIPT_HAN ) { panUniFonts = cjkFonts ; numFonts = WTF_ARRAY_LENGTH ( cjkFonts ) ; } else { panUniFonts = commonFonts ; numFonts = WTF_ARRAY_LENGTH ( commonFonts ) ; } int i ; for ( i = 0 ; ( ! data || ! fontContainsCharacter ( data , family , character ) ) && i < numFonts ; ++ i ) { family = panUniFonts [ i ] ; data = getFontPlatformData ( fontDescription , AtomicString ( family , wcslen ( family ) ) ) ; } if ( i <= numFonts ) return fontDataFromFontPlatformData ( data , DoNotRetain ) ; return nullptr ; }
Given the desired base font, this will create a SimpleFontData for a specific
font that can be used to render the given range of characters.
Given the desired base font this will create a SimpleFontData for a specific font that can be used to render the given range of characters .
// FIXME: Consider passing fontDescription.dominantScript() // to GetFallbackFamily here. // Last resort font list : PanUnicode. CJK fonts have a pretty // large repertoire. Eventually, we need to scan all the fonts // on the system to have a Firefox-like coverage. // Make sure that all of them are lowercased. // Partial CJK Ext. A coverage but more widely known to Chinese users. // Complete CJK Ext. A coverage. // Complete CJK Ext. A coverage. // CJK Ext. B fonts are not listed here because it's of no use // with our current non-BMP character handling because we use // Uniscribe for it and that code path does not go through here. // Six fonts below (and code2000 at the end) are not from MS, but // once installed, cover a very wide range of characters. // Font returned from getFallbackFamily may not cover |character| // because it's based on script to font mapping. This problem is // critical enough for non-Latin scripts (especially Han) to // warrant an additional (real coverage) check with fontCotainsCharacter. // When i-th font (0-base) in |panUniFonts| contains a character and // we get out of the loop, |i| will be |i + 1|. That is, if only the // last font in the array covers the character, |i| will be numFonts. // So, we have to use '<=" rather than '<' to see if we found a font // covering the character.