| 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 15 matching lines...) Expand all Loading... |
| 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 #include "platform/fonts/FontCache.h" | 32 #include "platform/fonts/FontCache.h" |
| 33 | 33 |
| 34 #include "SkFontMgr.h" | 34 #include "SkFontMgr.h" |
| 35 #include "SkTypeface_win.h" | 35 #include "SkTypeface_win.h" |
| 36 #include "platform/Language.h" | |
| 37 #include "platform/RuntimeEnabledFeatures.h" | 36 #include "platform/RuntimeEnabledFeatures.h" |
| 38 #include "platform/fonts/FontDescription.h" | 37 #include "platform/fonts/FontDescription.h" |
| 39 #include "platform/fonts/FontFaceCreationParams.h" | 38 #include "platform/fonts/FontFaceCreationParams.h" |
| 40 #include "platform/fonts/FontPlatformData.h" | 39 #include "platform/fonts/FontPlatformData.h" |
| 41 #include "platform/fonts/SimpleFontData.h" | 40 #include "platform/fonts/SimpleFontData.h" |
| 42 #include "platform/fonts/win/FontFallbackWin.h" | 41 #include "platform/fonts/win/FontFallbackWin.h" |
| 43 | 42 |
| 44 namespace blink { | 43 namespace blink { |
| 45 | 44 |
| 46 HashMap<String, RefPtr<SkTypeface>>* FontCache::s_sideloadedFonts = 0; | 45 HashMap<String, RefPtr<SkTypeface>>* FontCache::s_sideloadedFonts = 0; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 fontDescription.locale(), | 135 fontDescription.locale(), |
| 137 &script, | 136 &script, |
| 138 fallbackPriority, | 137 fallbackPriority, |
| 139 m_fontManager.get()); | 138 m_fontManager.get()); |
| 140 FontPlatformData* data = 0; | 139 FontPlatformData* data = 0; |
| 141 if (family) { | 140 if (family) { |
| 142 FontFaceCreationParams createByFamily(AtomicString(family, wcslen(family
))); | 141 FontFaceCreationParams createByFamily(AtomicString(family, wcslen(family
))); |
| 143 data = getFontPlatformData(fontDescription, createByFamily); | 142 data = getFontPlatformData(fontDescription, createByFamily); |
| 144 } | 143 } |
| 145 | 144 |
| 146 if ((!data || !data->fontContainsCharacter(character)) && s_useSkiaFontFallb
ack) { | |
| 147 const char* bcp47Locale = nullptr; | |
| 148 int localeCount = 0; | |
| 149 CString fontLocale; | |
| 150 // If the font description has a locale, use that. Otherwise, Skia will | |
| 151 // fall back on the user's default locale. | |
| 152 // TODO(kulshin): extract locale fallback logic from | |
| 153 // FontCacheAndroid.cpp and share that code | |
| 154 if (!fontDescription.locale().isEmpty()) { | |
| 155 fontLocale = toSkFontMgrLocale(fontDescription.locale()); | |
| 156 bcp47Locale = fontLocale.data(); | |
| 157 localeCount = 1; | |
| 158 } | |
| 159 | |
| 160 CString familyName = fontDescription.family().family().utf8(); | |
| 161 | |
| 162 SkTypeface* typeface = m_fontManager->matchFamilyStyleCharacter( | |
| 163 familyName.data(), | |
| 164 fontDescription.skiaFontStyle(), | |
| 165 &bcp47Locale, | |
| 166 localeCount, | |
| 167 character); | |
| 168 if (typeface) { | |
| 169 SkString skiaFamily; | |
| 170 typeface->getFamilyName(&skiaFamily); | |
| 171 FontFaceCreationParams createByFamily( | |
| 172 AtomicString(skiaFamily.c_str())); | |
| 173 data = getFontPlatformData(fontDescription, createByFamily); | |
| 174 } | |
| 175 } | |
| 176 | |
| 177 // Last resort font list : PanUnicode. CJK fonts have a pretty | 145 // Last resort font list : PanUnicode. CJK fonts have a pretty |
| 178 // large repertoire. Eventually, we need to scan all the fonts | 146 // large repertoire. Eventually, we need to scan all the fonts |
| 179 // on the system to have a Firefox-like coverage. | 147 // on the system to have a Firefox-like coverage. |
| 180 // Make sure that all of them are lowercased. | 148 // Make sure that all of them are lowercased. |
| 181 const static wchar_t* const cjkFonts[] = { | 149 const static wchar_t* const cjkFonts[] = { |
| 182 L"arial unicode ms", | 150 L"arial unicode ms", |
| 183 L"ms pgothic", | 151 L"ms pgothic", |
| 184 L"simsun", | 152 L"simsun", |
| 185 L"gulim", | 153 L"gulim", |
| 186 L"pmingliu", | 154 L"pmingliu", |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 if (typefacesMatchesFamily(tf.get(), family)) { | 422 if (typefacesMatchesFamily(tf.get(), family)) { |
| 455 result->setMinSizeForSubpixel(minSizeForSubpixelForFont); | 423 result->setMinSizeForSubpixel(minSizeForSubpixelForFont); |
| 456 break; | 424 break; |
| 457 } | 425 } |
| 458 } | 426 } |
| 459 | 427 |
| 460 return result.release(); | 428 return result.release(); |
| 461 } | 429 } |
| 462 | 430 |
| 463 } // namespace blink | 431 } // namespace blink |
| OLD | NEW |