Changeset 60953 in webkit
- Timestamp:
- Jun 10, 2010 6:31:06 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r60952 r60953 1 2010-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 1 26 2010-06-09 Andrei Popescu <andreip@google.com> 2 27 -
trunk/WebCore/platform/graphics/chromium/FontUtilsChromiumWin.cpp
r55870 r60953 1 1 /* 2 * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved.2 * Copyright (c) 2006, 2007, 2008, 2009, 2010, Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 45 45 namespace { 46 46 47 bool 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 47 66 // A simple mapping from UScriptCode to family name. This is a sparse array, 48 67 // which works well since the range of UScriptCode values is small. … … 56 75 }; 57 76 58 const staticFontMap fontMap[] = {77 static const FontMap fontMap[] = { 59 78 {USCRIPT_LATIN, L"times new roman"}, 60 79 {USCRIPT_GREEK, L"times new roman"}, 61 80 {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. 62 85 {USCRIPT_SIMPLIFIED_HAN, L"simsun"}, 63 86 {USCRIPT_TRADITIONAL_HAN, L"pmingliu"}, … … 73 96 {USCRIPT_GURMUKHI, L"raavi"}, 74 97 {USCRIPT_GUJARATI, L"shruti"}, 75 {USCRIPT_ORIYA, L"kalinga"},76 98 {USCRIPT_TAMIL, L"latha"}, 77 99 {USCRIPT_TELUGU, L"gautami"}, 78 100 {USCRIPT_KANNADA, L"tunga"}, 79 {USCRIPT_MALAYALAM, L"kartika"},80 {USCRIPT_LAO, L"dokchampa"},81 {USCRIPT_TIBETAN, L"microsoft himalaya"},82 101 {USCRIPT_GEORGIAN, L"sylfaen"}, 83 102 {USCRIPT_ARMENIAN, L"sylfaen"}, 84 {USCRIPT_ ETHIOPIC, L"nyala"},103 {USCRIPT_THAANA, L"mv boli"}, 85 104 {USCRIPT_CANADIAN_ABORIGINAL, L"euphemia"}, 86 105 {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"},92 106 {USCRIPT_MONGOLIAN, L"mongolian balti"}, 93 {USCRIPT_MYANMAR, L"padauk"},94 107 // For USCRIPT_COMMON, we map blocks to scripts when 95 108 // that makes sense. 96 109 }; 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 98 153 for (int i = 0; i < sizeof(fontMap) / sizeof(fontMap[0]); ++i) 99 154 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 } 100 172 101 173 // Initialize the locale-dependent mapping. … … 199 271 typedef HashMap<String, FontData> FontDataCache; 200 272 201 } 273 } // namespace 202 274 203 275 // FIXME: this is font fallback code version 0.1 … … 364 436 } 365 437 366 } 438 } // namespace WebCore
Note: See TracChangeset
for help on using the changeset viewer.