| 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, 2012 Google Inc. All rights reserved. | 3 * Copyright (c) 2006, 2007, 2008, 2009, 2012 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 27 matching lines...) Expand all Loading... |
| 38 #include "platform/fonts/FontDescription.h" | 38 #include "platform/fonts/FontDescription.h" |
| 39 #include "platform/fonts/FontFaceCreationParams.h" | 39 #include "platform/fonts/FontFaceCreationParams.h" |
| 40 #include "platform/fonts/FontPlatformData.h" | 40 #include "platform/fonts/FontPlatformData.h" |
| 41 #include "platform/fonts/SimpleFontData.h" | 41 #include "platform/fonts/SimpleFontData.h" |
| 42 #include "platform/fonts/win/FontFallbackWin.h" | 42 #include "platform/fonts/win/FontFallbackWin.h" |
| 43 | 43 |
| 44 namespace blink { | 44 namespace blink { |
| 45 | 45 |
| 46 HashMap<String, RefPtr<SkTypeface> >* FontCache::s_sideloadedFonts = 0; | 46 HashMap<String, RefPtr<SkTypeface> >* FontCache::s_sideloadedFonts = 0; |
| 47 | 47 |
| 48 // Cached system font metrics. |
| 49 AtomicString* FontCache::s_menuFontFamilyName = 0; |
| 50 int32_t FontCache::s_menuFontHeight = 0; |
| 51 AtomicString* FontCache::s_smallCaptionFontFamilyName = 0; |
| 52 int32_t FontCache::s_smallCaptionFontHeight = 0; |
| 53 AtomicString* FontCache::s_statusFontFamilyName = 0; |
| 54 int32_t FontCache::s_statusFontHeight = 0; |
| 55 |
| 56 namespace { |
| 57 |
| 58 int32_t ensureMinimumFontHeightIfNeeded(int32_t fontHeight) |
| 59 { |
| 60 // Adjustment for codepage 936 to make the fonts more legible in Simplified
Chinese. |
| 61 // Please refer to RenderThemeChromiumFontProviderWin.cpp for more informati
on. |
| 62 return (fontHeight < 12.0f) && (GetACP() == 936) ? 12.0f : fontHeight; |
| 63 } |
| 64 |
| 65 } // namespace |
| 66 |
| 48 // static | 67 // static |
| 49 void FontCache::addSideloadedFontForTesting(SkTypeface* typeface) | 68 void FontCache::addSideloadedFontForTesting(SkTypeface* typeface) |
| 50 { | 69 { |
| 51 if (!s_sideloadedFonts) | 70 if (!s_sideloadedFonts) |
| 52 s_sideloadedFonts = new HashMap<String, RefPtr<SkTypeface> >; | 71 s_sideloadedFonts = new HashMap<String, RefPtr<SkTypeface> >; |
| 53 SkString name; | 72 SkString name; |
| 54 typeface->getFamilyName(&name); | 73 typeface->getFamilyName(&name); |
| 55 s_sideloadedFonts->set(name.c_str(), adoptRef(typeface)); | 74 s_sideloadedFonts->set(name.c_str(), adoptRef(typeface)); |
| 56 } | 75 } |
| 57 | 76 |
| 77 // static |
| 78 void FontCache::setMenuFontMetrics(const wchar_t* familyName, int32_t fontHeight
) |
| 79 { |
| 80 s_menuFontFamilyName = new AtomicString(familyName); |
| 81 s_menuFontHeight = ensureMinimumFontHeightIfNeeded(fontHeight); |
| 82 } |
| 83 |
| 84 // static |
| 85 void FontCache::setSmallCaptionFontMetrics(const wchar_t* familyName, int32_t fo
ntHeight) |
| 86 { |
| 87 s_smallCaptionFontFamilyName = new AtomicString(familyName); |
| 88 s_smallCaptionFontHeight = ensureMinimumFontHeightIfNeeded(fontHeight); |
| 89 } |
| 90 |
| 91 // static |
| 92 void FontCache::setStatusFontMetrics(const wchar_t* familyName, int32_t fontHeig
ht) |
| 93 { |
| 94 s_statusFontFamilyName = new AtomicString(familyName); |
| 95 s_statusFontHeight = ensureMinimumFontHeightIfNeeded(fontHeight); |
| 96 } |
| 97 |
| 58 FontCache::FontCache() | 98 FontCache::FontCache() |
| 59 : m_purgePreventCount(0) | 99 : m_purgePreventCount(0) |
| 60 { | 100 { |
| 61 SkFontMgr* fontManager; | 101 SkFontMgr* fontManager; |
| 62 | 102 |
| 63 if (s_useDirectWrite) { | 103 if (s_useDirectWrite) { |
| 64 fontManager = SkFontMgr_New_DirectWrite(s_directWriteFactory); | 104 fontManager = SkFontMgr_New_DirectWrite(s_directWriteFactory); |
| 65 s_useSubpixelPositioning = true; | 105 s_useSubpixelPositioning = true; |
| 66 } else { | 106 } else { |
| 67 fontManager = SkFontMgr_New_GDI(); | 107 fontManager = SkFontMgr_New_GDI(); |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 if (typefacesMatchesFamily(tf.get(), family)) { | 421 if (typefacesMatchesFamily(tf.get(), family)) { |
| 382 result->setMinSizeForSubpixel(minSizeForSubpixelForFont); | 422 result->setMinSizeForSubpixel(minSizeForSubpixelForFont); |
| 383 break; | 423 break; |
| 384 } | 424 } |
| 385 } | 425 } |
| 386 | 426 |
| 387 return result; | 427 return result; |
| 388 } | 428 } |
| 389 | 429 |
| 390 } // namespace blink | 430 } // namespace blink |
| OLD | NEW |