| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 HashMap<String, RefPtr<SkTypeface>>* FontCache::s_sideloadedFonts = 0; | 45 HashMap<String, RefPtr<SkTypeface>>* FontCache::s_sideloadedFonts = 0; |
| 46 | 46 |
| 47 // Cached system font metrics. | 47 // Cached system font metrics. |
| 48 AtomicString* FontCache::s_menuFontFamilyName = 0; | 48 AtomicString* FontCache::s_menuFontFamilyName = 0; |
| 49 int32_t FontCache::s_menuFontHeight = 0; | 49 int32_t FontCache::s_menuFontHeight = 0; |
| 50 AtomicString* FontCache::s_smallCaptionFontFamilyName = 0; | 50 AtomicString* FontCache::s_smallCaptionFontFamilyName = 0; |
| 51 int32_t FontCache::s_smallCaptionFontHeight = 0; | 51 int32_t FontCache::s_smallCaptionFontHeight = 0; |
| 52 AtomicString* FontCache::s_statusFontFamilyName = 0; | 52 AtomicString* FontCache::s_statusFontFamilyName = 0; |
| 53 int32_t FontCache::s_statusFontHeight = 0; | 53 int32_t FontCache::s_statusFontHeight = 0; |
| 54 | 54 |
| 55 UScriptCode FontCache::m_preferredScriptForHan = USCRIPT_COMMON; |
| 56 |
| 55 namespace { | 57 namespace { |
| 56 | 58 |
| 57 int32_t ensureMinimumFontHeightIfNeeded(int32_t fontHeight) | 59 int32_t ensureMinimumFontHeightIfNeeded(int32_t fontHeight) |
| 58 { | 60 { |
| 59 // Adjustment for codepage 936 to make the fonts more legible in Simplified
Chinese. | 61 // Adjustment for codepage 936 to make the fonts more legible in Simplified
Chinese. |
| 60 // Please refer to LayoutThemeFontProviderWin.cpp for more information. | 62 // Please refer to LayoutThemeFontProviderWin.cpp for more information. |
| 61 return (fontHeight < 12.0f) && (GetACP() == 936) ? 12.0f : fontHeight; | 63 return (fontHeight < 12.0f) && (GetACP() == 936) ? 12.0f : fontHeight; |
| 62 } | 64 } |
| 63 | 65 |
| 64 } // namespace | 66 } // namespace |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 } else { | 107 } else { |
| 106 fontManager = SkFontMgr_New_GDI(); | 108 fontManager = SkFontMgr_New_GDI(); |
| 107 // Subpixel text positioning is not supported by the GDI backend. | 109 // Subpixel text positioning is not supported by the GDI backend. |
| 108 s_useSubpixelPositioning = false; | 110 s_useSubpixelPositioning = false; |
| 109 } | 111 } |
| 110 | 112 |
| 111 ASSERT(fontManager); | 113 ASSERT(fontManager); |
| 112 m_fontManager = adoptPtr(fontManager); | 114 m_fontManager = adoptPtr(fontManager); |
| 113 } | 115 } |
| 114 | 116 |
| 115 void FontCache::acceptLanguagesChanged(const String&) | 117 void FontCache::acceptLanguagesChanged(const String& acceptLanguages) |
| 116 { | 118 { |
| 117 // TODO(kojii): Take acceptLanguages into account for ambiguos scripts. | 119 // Use the UI locale if it can disambiguate the Unified Han. |
| 120 // Since Chrome synchronizes the ICU default locale with its UI locale, |
| 121 // this ICU locale tells the current UI locale of Chrome. |
| 122 m_preferredScriptForHan = scriptCodeForHanFromLocale( |
| 123 icu::Locale::getDefault().getName(), '_'); |
| 124 if (m_preferredScriptForHan != USCRIPT_COMMON) |
| 125 return; |
| 126 |
| 127 // Use acceptLanguages if it has languages that can disambiguate. |
| 128 Vector<String> languages; |
| 129 acceptLanguages.split(',', languages); |
| 130 for (String token : languages) { |
| 131 token = token.stripWhiteSpace(); |
| 132 m_preferredScriptForHan = scriptCodeForHanFromLocale(token); |
| 133 if (m_preferredScriptForHan != USCRIPT_COMMON) |
| 134 return; |
| 135 } |
| 118 } | 136 } |
| 119 | 137 |
| 120 // Given the desired base font, this will create a SimpleFontData for a specific | 138 // Given the desired base font, this will create a SimpleFontData for a specific |
| 121 // font that can be used to render the given range of characters. | 139 // font that can be used to render the given range of characters. |
| 122 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter( | 140 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter( |
| 123 const FontDescription& fontDescription, UChar32 character, | 141 const FontDescription& fontDescription, UChar32 character, |
| 124 const SimpleFontData* originalFontData) | 142 const SimpleFontData* originalFontData) |
| 125 { | 143 { |
| 126 // First try the specified font with standard style & weight. | 144 // First try the specified font with standard style & weight. |
| 127 if (fontDescription.style() == FontStyleItalic | 145 if (fontDescription.style() == FontStyleItalic |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 if (typefacesMatchesFamily(tf.get(), family)) { | 442 if (typefacesMatchesFamily(tf.get(), family)) { |
| 425 result->setMinSizeForSubpixel(minSizeForSubpixelForFont); | 443 result->setMinSizeForSubpixel(minSizeForSubpixelForFont); |
| 426 break; | 444 break; |
| 427 } | 445 } |
| 428 } | 446 } |
| 429 | 447 |
| 430 return result.release(); | 448 return result.release(); |
| 431 } | 449 } |
| 432 | 450 |
| 433 } // namespace blink | 451 } // namespace blink |
| OLD | NEW |