Changeset 60953 in webkit


Ignore:
Timestamp:
Jun 10, 2010 6:31:06 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-06-10 Jungshik Shin <jshin@chromium.org>

Reviewed by Kent Tamura

Bug 38224 - [chromium] Enable rendering of Ethiopic, Lao, Tibetan

and a few other scripts on Win XP

https://bugs.webkit.org/show_bug.cgi?id=38224

Make it possible to specify a list of fonts for per-script
fallback instead of a single font per script. This is
necessary for Malayalam (for which Windows font doesn't
support Unicode 5.x fully on Vista or earlier), Ethiopic
(we want to support on XP with a 3rd party font because XP
doesn't have any Ethiopic font out of the box) and some other
scripts. This is a short-term 'fix' until we have per-script
font preferences.

No layout test is added because the test results would be
dependent on which fonts are present.

  • platform/graphics/chromium/FontUtilsChromiumWin.cpp: (WebCore::): (WebCore::FontMap::ScriptToFontFamilies::):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r60952 r60953  
     12010-06-10  Jungshik Shin  <jshin@chromium.org>
     2
     3        Reviewed by Kent Tamura
     4
     5        Bug 38224 - [chromium] Enable rendering of Ethiopic, Lao, Tibetan
     6                    and a few other scripts on Win XP
     7
     8        https://bugs.webkit.org/show_bug.cgi?id=38224
     9
     10        Make it possible to specify a list of fonts for per-script
     11        fallback instead of a single font per script. This is
     12        necessary for Malayalam (for which Windows font doesn't
     13        support Unicode 5.x fully on Vista or earlier), Ethiopic
     14        (we want to support on XP with a 3rd party font because XP
     15        doesn't have any Ethiopic font out of the box) and some other
     16        scripts. This is a short-term 'fix' until we have per-script
     17        font preferences.
     18
     19        No layout test is added because the test results would be
     20        dependent on which fonts are present.
     21
     22        * platform/graphics/chromium/FontUtilsChromiumWin.cpp:
     23        (WebCore::):
     24        (WebCore::FontMap::ScriptToFontFamilies::):
     25
    1262010-06-09  Andrei Popescu  <andreip@google.com>
    227
  • trunk/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp

    r55870 r60953  
    11/*
    2  * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved.
     2 * Copyright (c) 2006, 2007, 2008, 2009, 2010, Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4545namespace {
    4646
     47bool isFontPresent(const UChar* fontName)
     48{
     49    HFONT hfont = CreateFont(12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     50                             fontName);
     51    if (!hfont)
     52        return false;
     53    HDC dc = GetDC(0);
     54    HGDIOBJ oldFont = static_cast<HFONT>(SelectObject(dc, hfont));
     55    WCHAR actualFontName[LF_FACESIZE];
     56    GetTextFace(dc, LF_FACESIZE, actualFontName);
     57    actualFontName[LF_FACESIZE - 1] = 0;
     58    SelectObject(dc, oldFont);
     59    DeleteObject(hfont);
     60    ReleaseDC(0, dc);
     61    // We don't have to worry about East Asian fonts with locale-dependent
     62    // names here for now.
     63    return !wcscmp(fontName, actualFontName);
     64}
     65
    4766// A simple mapping from UScriptCode to family name.  This is a sparse array,
    4867// which works well since the range of UScriptCode values is small.
     
    5675    };
    5776
    58     const static FontMap fontMap[] = {
     77    static const FontMap fontMap[] = {
    5978        {USCRIPT_LATIN, L"times new roman"},
    6079        {USCRIPT_GREEK, L"times new roman"},
    6180        {USCRIPT_CYRILLIC, L"times new roman"},
     81        // FIXME: Consider trying new Vista fonts before XP fonts for CJK.
     82        // Some Vista users do want to use Vista cleartype CJK fonts. If we
     83        // did, the results of tests with CJK characters would have to be
     84        // regenerated for Vista.
    6285        {USCRIPT_SIMPLIFIED_HAN, L"simsun"},
    6386        {USCRIPT_TRADITIONAL_HAN, L"pmingliu"},
     
    7396        {USCRIPT_GURMUKHI, L"raavi"},
    7497        {USCRIPT_GUJARATI, L"shruti"},
    75         {USCRIPT_ORIYA, L"kalinga"},
    7698        {USCRIPT_TAMIL, L"latha"},
    7799        {USCRIPT_TELUGU, L"gautami"},
    78100        {USCRIPT_KANNADA, L"tunga"},
    79         {USCRIPT_MALAYALAM, L"kartika"},
    80         {USCRIPT_LAO, L"dokchampa"},
    81         {USCRIPT_TIBETAN, L"microsoft himalaya"},
    82101        {USCRIPT_GEORGIAN, L"sylfaen"},
    83102        {USCRIPT_ARMENIAN, L"sylfaen"},
    84         {USCRIPT_ETHIOPIC, L"nyala"},
     103        {USCRIPT_THAANA, L"mv boli"},
    85104        {USCRIPT_CANADIAN_ABORIGINAL, L"euphemia"},
    86105        {USCRIPT_CHEROKEE, L"plantagenet cherokee"},
    87         {USCRIPT_YI, L"microsoft yi balti"},
    88         {USCRIPT_SINHALA, L"iskoola pota"},
    89         {USCRIPT_SYRIAC, L"estrangelo edessa"},
    90         {USCRIPT_KHMER, L"daunpenh"},
    91         {USCRIPT_THAANA, L"mv boli"},
    92106        {USCRIPT_MONGOLIAN, L"mongolian balti"},
    93         {USCRIPT_MYANMAR, L"padauk"},
    94107        // For USCRIPT_COMMON, we map blocks to scripts when
    95108        // that makes sense.
    96109    };
    97    
     110
     111    struct ScriptToFontFamilies {
     112        UScriptCode script;
     113        const UChar** families;
     114    };
     115
     116    // Kartika on Vista or earlier lacks the support for Chillu
     117    // letters added to Unicode 5.1.
     118    // Try AnjaliOldLipi (a very widely used Malaylalam font with the full
     119    // Unicode 5.x support) before falling back to Kartika.
     120    static const UChar* malayalamFonts[] = {L"AnjaliOldLipi", L"Lohit Malayalam", L"Kartika", L"Rachana", 0};
     121    // Try Khmer OS before Vista fonts because 'Khmer OS' goes along better
     122    // with Latin and looks better/larger for the same size.
     123    static const UChar* khmerFonts[] = {L"Khmer OS", L"MoolBoran", L"DaunPenh", L"Code2000", 0};
     124    // For the following 6 scripts, two or fonts are listed. The fonts in
     125    // the 1st slot are not available on Windows XP. To support these
     126    // scripts on XP, listed in the rest of slots are widely used
     127    // fonts.
     128    static const UChar* ethiopicFonts[] = {L"Nyala", L"Abyssinica SIL", L"Ethiopia Jiret", L"Visual Geez Unicode", L"GF Zemen Unicode", 0};
     129    static const UChar* oriyaFonts[] = {L"Kalinga", L"ori1Uni", L"Lohit Oriya", 0};
     130    static const UChar* laoFonts[] = {L"DokChampa", L"Saysettha OT", L"Phetsarath OT", L"Code2000", 0};
     131    static const UChar* tibetanFonts[] = {L"Microsoft Himalaya", L"Jomolhari", L"Tibetan Machine Uni", 0};
     132    static const UChar* sinhalaFonts[] = {L"Iskoola Pota", L"AksharUnicode", 0};
     133    static const UChar* yiFonts[] = {L"Microsoft Yi Balti", L"Nuosu SIL", L"Code2000", 0};
     134    // http://www.bethmardutho.org/support/meltho/download/index.php
     135    static const UChar* syriacFonts[] = {L"Estrangelo Edessa", L"Estrangelo Nisibin", L"Code2000", 0};
     136    // No Myanmar/Burmese font is shipped with Windows, yet. Try a few
     137    // widely available/used ones that supports Unicode 5.1 or later.
     138    static const UChar* myanmarFonts[] = {L"Padauk", L"Parabaik", L"Myanmar3", L"Code2000", 0};
     139
     140    static const ScriptToFontFamilies scriptToFontFamilies[] = {
     141        {USCRIPT_MALAYALAM, malayalamFonts},
     142        {USCRIPT_KHMER, khmerFonts},
     143        {USCRIPT_ETHIOPIC, ethiopicFonts},
     144        {USCRIPT_ORIYA, oriyaFonts},
     145        {USCRIPT_LAO, laoFonts},
     146        {USCRIPT_TIBETAN, tibetanFonts},
     147        {USCRIPT_SINHALA, sinhalaFonts},
     148        {USCRIPT_YI, yiFonts},
     149        {USCRIPT_SYRIAC, syriacFonts},
     150        {USCRIPT_MYANMAR, myanmarFonts},
     151    };
     152
    98153    for (int i = 0; i < sizeof(fontMap) / sizeof(fontMap[0]); ++i)
    99154        scriptFontMap[fontMap[i].script] = fontMap[i].family;
     155
     156    // FIXME: Instead of scanning the hard-coded list, we have to
     157    // use EnumFont* to 'inspect' fonts to pick up fonts covering scripts
     158    // when it's possible (e.g. using OS/2 table). If we do that, this
     159    // had better be pulled out of here.
     160    for (int i = 0; i < sizeof(scriptToFontFamilies) / sizeof(scriptToFontFamilies[0]); ++i) {
     161        UScriptCode script = scriptToFontFamilies[i].script;
     162        scriptFontMap[script] = 0;
     163        const UChar** familyPtr = scriptToFontFamilies[i].families;
     164        while (*familyPtr) {
     165            if (isFontPresent(*familyPtr)) {
     166                scriptFontMap[script] = *familyPtr;
     167                break;
     168            }
     169            ++familyPtr;
     170        }
     171    }
    100172
    101173    // Initialize the locale-dependent mapping.
     
    199271typedef HashMap<String, FontData> FontDataCache;
    200272
    201 }  // namespace
     273} // namespace
    202274
    203275// FIXME: this is font fallback code version 0.1
     
    364436}
    365437
    366 }  // namespace WebCore
     438} // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.