Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(579)

Side by Side Diff: Source/platform/fonts/win/FontFallbackWin.cpp

Issue 1314543011: Add fallback fonts for math and symbol blocks on Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2012 Google Inc. All rights reser ved. 2 * Copyright (c) 2006, 2007, 2008, 2009, 2010, 2012 Google Inc. All rights reser ved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // If script is invalid, common or inherited or there's an error, 278 // If script is invalid, common or inherited or there's an error,
279 // infer a script based on the unicode block of a character. 279 // infer a script based on the unicode block of a character.
280 if (script <= USCRIPT_INHERITED || U_FAILURE(err)) 280 if (script <= USCRIPT_INHERITED || U_FAILURE(err))
281 script = getScriptBasedOnUnicodeBlock(ucs4); 281 script = getScriptBasedOnUnicodeBlock(ucs4);
282 return script; 282 return script;
283 } 283 }
284 284
285 const UChar* getFontBasedOnUnicodeBlock(int ucs4, SkFontMgr* fontManager) 285 const UChar* getFontBasedOnUnicodeBlock(int ucs4, SkFontMgr* fontManager)
286 { 286 {
287 static const UChar* emojiFonts[] = {L"Segoe UI Emoji", L"Segoe UI Symbol"}; 287 static const UChar* emojiFonts[] = {L"Segoe UI Emoji", L"Segoe UI Symbol"};
288 static const UChar* mathFonts[] = {L"Cambria Math", L"Segoe UI Symbol", L"Co de2000"};
288 static const UChar* symbolFont = L"Segoe UI Symbol"; 289 static const UChar* symbolFont = L"Segoe UI Symbol";
289 static const UChar* emojiFont = 0; 290 static const UChar* emojiFont = 0;
291 static const UChar* mathFont = 0;
290 static bool initialized = false; 292 static bool initialized = false;
291 if (!initialized) { 293 if (!initialized) {
292 for (size_t i = 0; i < WTF_ARRAY_LENGTH(emojiFonts); i++) { 294 for (size_t i = 0; i < WTF_ARRAY_LENGTH(emojiFonts); i++) {
293 if (isFontPresent(emojiFonts[i], fontManager)) { 295 if (isFontPresent(emojiFonts[i], fontManager)) {
294 emojiFont = emojiFonts[i]; 296 emojiFont = emojiFonts[i];
295 break; 297 break;
296 } 298 }
297 } 299 }
300 for (size_t i = 0; i < WTF_ARRAY_LENGTH(mathFonts); i++) {
301 if (isFontPresent(mathFonts[i], fontManager)) {
302 mathFont = mathFonts[i];
303 break;
304 }
305 }
298 initialized = true; 306 initialized = true;
299 } 307 }
300 308
301 UBlockCode block = ublock_getCode(ucs4); 309 UBlockCode block = ublock_getCode(ucs4);
302 switch (block) { 310 switch (block) {
303 case UBLOCK_EMOTICONS: 311 case UBLOCK_EMOTICONS:
ebraminio 2015/09/04 19:56:45 I suggest adding UBLOCK_ENCLOSED_ALPHANUMERIC_SUPP
304 return emojiFont; 312 return emojiFont;
305 case UBLOCK_PLAYING_CARDS: 313 case UBLOCK_PLAYING_CARDS:
306 case UBLOCK_MISCELLANEOUS_SYMBOLS: 314 case UBLOCK_MISCELLANEOUS_SYMBOLS:
315 case UBLOCK_MISCELLANEOUS_SYMBOLS_AND_ARROWS:
307 case UBLOCK_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS: 316 case UBLOCK_MISCELLANEOUS_SYMBOLS_AND_PICTOGRAPHS:
308 case UBLOCK_MISCELLANEOUS_TECHNICAL:
309 case UBLOCK_TRANSPORT_AND_MAP_SYMBOLS: 317 case UBLOCK_TRANSPORT_AND_MAP_SYMBOLS:
310 case UBLOCK_ALCHEMICAL_SYMBOLS: 318 case UBLOCK_ALCHEMICAL_SYMBOLS:
311 case UBLOCK_RUNIC: 319 case UBLOCK_RUNIC:
312 case UBLOCK_SUPPLEMENTAL_MATHEMATICAL_OPERATORS:
313 case UBLOCK_DINGBATS: 320 case UBLOCK_DINGBATS:
ebraminio 2015/09/04 19:56:45 I guess adding UBLOCK_GOTHIC here would resolve Go
314 return symbolFont; 321 return symbolFont;
322 case UBLOCK_ARROWS:
323 case UBLOCK_MATHEMATICAL_OPERATORS:
324 case UBLOCK_MISCELLANEOUS_TECHNICAL:
325 case UBLOCK_GEOMETRIC_SHAPES:
326 case UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A:
327 case UBLOCK_SUPPLEMENTAL_ARROWS_A:
328 case UBLOCK_SUPPLEMENTAL_ARROWS_B:
329 case UBLOCK_MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B:
330 case UBLOCK_SUPPLEMENTAL_MATHEMATICAL_OPERATORS:
331 case UBLOCK_MATHEMATICAL_ALPHANUMERIC_SYMBOLS:
332 case UBLOCK_ARABIC_MATHEMATICAL_ALPHABETIC_SYMBOLS:
333 case UBLOCK_GEOMETRIC_SHAPES_EXTENDED:
334 return mathFont;
315 default: 335 default:
316 return 0; 336 return 0;
317 }; 337 };
318 } 338 }
319 339
320 } // namespace 340 } // namespace
321 341
322 // FIXME: this is font fallback code version 0.1 342 // FIXME: this is font fallback code version 0.1
323 // - Cover all the scripts 343 // - Cover all the scripts
324 // - Get the default font for each script/generic family from the 344 // - Get the default font for each script/generic family from the
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 family = L"lucida sans unicode"; 431 family = L"lucida sans unicode";
412 } 432 }
413 } 433 }
414 434
415 if (scriptChecked) 435 if (scriptChecked)
416 *scriptChecked = script; 436 *scriptChecked = script;
417 return family; 437 return family;
418 } 438 }
419 439
420 } // namespace blink 440 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698