OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007 Apple Computer, Inc. | 2 * Copyright (C) 2006, 2007 Apple Computer, Inc. |
3 * Copyright (c) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 3 * Copyright (c) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 } | 407 } |
408 | 408 |
409 FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font) | 409 FontPlatformData* FontCache::getSimilarFontPlatformData(const Font& font) |
410 { | 410 { |
411 return 0; | 411 return 0; |
412 } | 412 } |
413 | 413 |
414 FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& de
scription) | 414 FontPlatformData* FontCache::getLastResortFallbackFont(const FontDescription& de
scription) |
415 { | 415 { |
416 FontDescription::GenericFamilyType generic = description.genericFamily(); | 416 FontDescription::GenericFamilyType generic = description.genericFamily(); |
417 // FIXME: Mapping webkit generic to GenericFamilyType needs to | |
418 // be more intelligent. | |
419 // This spot rarely gets reached. GetFontDataForCharacters() gets hit a lot | |
420 // more often (see FIXME comment there). | |
421 const wchar_t* family = getFontFamilyForScript(description.dominantScript(),
generic); | |
422 | |
423 if (family) | |
424 return getCachedFontPlatformData(description, AtomicString(family, wcsle
n(family))); | |
425 | 417 |
426 // FIXME: Would be even better to somehow get the user's default font here. | 418 // FIXME: Would be even better to somehow get the user's default font here. |
427 // For now we'll pick the default that the user would get without changing | 419 // For now we'll pick the default that the user would get without changing |
428 // any prefs. | 420 // any prefs. |
429 static AtomicString timesStr("Times New Roman"); | 421 static AtomicString timesStr("Times New Roman"); |
430 static AtomicString courierStr("Courier New"); | 422 static AtomicString courierStr("Courier New"); |
431 static AtomicString arialStr("Arial"); | 423 static AtomicString arialStr("Arial"); |
432 | 424 |
433 AtomicString& fontStr = timesStr; | 425 AtomicString& fontStr = timesStr; |
434 if (generic == FontDescription::SansSerifFamily) | 426 if (generic == FontDescription::SansSerifFamily) |
(...skipping 13 matching lines...) Expand all Loading... |
448 FW_NORMAL, // FontWeight400 | 440 FW_NORMAL, // FontWeight400 |
449 FW_MEDIUM, // FontWeight500 | 441 FW_MEDIUM, // FontWeight500 |
450 FW_SEMIBOLD, // FontWeight600 | 442 FW_SEMIBOLD, // FontWeight600 |
451 FW_BOLD, // FontWeight700 | 443 FW_BOLD, // FontWeight700 |
452 FW_EXTRABOLD, // FontWeight800 | 444 FW_EXTRABOLD, // FontWeight800 |
453 FW_HEAVY // FontWeight900 | 445 FW_HEAVY // FontWeight900 |
454 }; | 446 }; |
455 return gdiFontWeights[fontWeight]; | 447 return gdiFontWeights[fontWeight]; |
456 } | 448 } |
457 | 449 |
458 // FIXME: This may not be the best place to put this function | |
459 AtomicString FontCache::getGenericFontForScript(UScriptCode script, const FontDe
scription& description) | |
460 { | |
461 const wchar_t* scriptFont = getFontFamilyForScript( script, description.gene
ricFamily()); | |
462 return scriptFont ? AtomicString(scriptFont, wcslen(scriptFont)) : emptyAtom
; | |
463 } | |
464 | |
465 static void FillLogFont(const FontDescription& fontDescription, LOGFONT* winfont
) | 450 static void FillLogFont(const FontDescription& fontDescription, LOGFONT* winfont
) |
466 { | 451 { |
467 // The size here looks unusual. The negative number is intentional. | 452 // The size here looks unusual. The negative number is intentional. |
468 // Unlike WebKit trunk, we don't multiply the size by 32. That seems to be | 453 // Unlike WebKit trunk, we don't multiply the size by 32. That seems to be |
469 // some kind of artifact of their CG backend, or something. | 454 // some kind of artifact of their CG backend, or something. |
470 winfont->lfHeight = -fontDescription.computedPixelSize(); | 455 winfont->lfHeight = -fontDescription.computedPixelSize(); |
471 winfont->lfWidth = 0; | 456 winfont->lfWidth = 0; |
472 winfont->lfEscapement = 0; | 457 winfont->lfEscapement = 0; |
473 winfont->lfOrientation = 0; | 458 winfont->lfOrientation = 0; |
474 winfont->lfUnderline = false; | 459 winfont->lfUnderline = false; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 DeleteObject(hfont); | 543 DeleteObject(hfont); |
559 return 0; | 544 return 0; |
560 } | 545 } |
561 } | 546 } |
562 | 547 |
563 return new FontPlatformData(hfont, | 548 return new FontPlatformData(hfont, |
564 fontDescription.computedPixelSize()); | 549 fontDescription.computedPixelSize()); |
565 } | 550 } |
566 | 551 |
567 } | 552 } |
OLD | NEW |