Chromium Code Reviews| 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" | |
| 36 #include "platform/RuntimeEnabledFeatures.h" | 37 #include "platform/RuntimeEnabledFeatures.h" |
| 37 #include "platform/fonts/FontDescription.h" | 38 #include "platform/fonts/FontDescription.h" |
| 38 #include "platform/fonts/FontFaceCreationParams.h" | 39 #include "platform/fonts/FontFaceCreationParams.h" |
| 39 #include "platform/fonts/FontPlatformData.h" | 40 #include "platform/fonts/FontPlatformData.h" |
| 40 #include "platform/fonts/SimpleFontData.h" | 41 #include "platform/fonts/SimpleFontData.h" |
| 41 #include "platform/fonts/win/FontFallbackWin.h" | 42 #include "platform/fonts/win/FontFallbackWin.h" |
| 42 | 43 |
| 43 namespace blink { | 44 namespace blink { |
| 44 | 45 |
| 45 HashMap<String, RefPtr<SkTypeface>>* FontCache::s_sideloadedFonts = 0; | 46 HashMap<String, RefPtr<SkTypeface>>* FontCache::s_sideloadedFonts = 0; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 fontDescription.script(), | 133 fontDescription.script(), |
| 133 fontDescription.locale(), | 134 fontDescription.locale(), |
| 134 &script, | 135 &script, |
| 135 m_fontManager.get()); | 136 m_fontManager.get()); |
| 136 FontPlatformData* data = 0; | 137 FontPlatformData* data = 0; |
| 137 if (family) { | 138 if (family) { |
| 138 FontFaceCreationParams createByFamily(AtomicString(family, wcslen(family ))); | 139 FontFaceCreationParams createByFamily(AtomicString(family, wcslen(family ))); |
| 139 data = getFontPlatformData(fontDescription, createByFamily); | 140 data = getFontPlatformData(fontDescription, createByFamily); |
| 140 } | 141 } |
| 141 | 142 |
| 143 if (!data || !data->fontContainsCharacter(character)) { | |
| 144 const char* bcp47Locale = nullptr; | |
| 145 int localeCount = 0; | |
| 146 CString fontLocale; | |
| 147 // If the font description has a locale, use that. Otherwise, Skia will fall back | |
|
eae
2016/02/29 23:11:26
Wrap at 80 col, you'll probably do a better job of
Ilya Kulshin
2016/03/01 03:31:14
Done.
| |
| 148 // on the user's default locale. | |
| 149 // TODO(kulshin): extract locale fallback logic from FontCacheAndroid.cp p and share that code | |
| 150 if (!fontDescription.locale().isEmpty()) { | |
| 151 fontLocale = toSkFontMgrLocale(fontDescription.locale()); | |
| 152 bcp47Locale = fontLocale.data(); | |
| 153 localeCount = 1; | |
|
eae
2016/02/29 23:11:26
This is set but never used. Please remove.
Ilya Kulshin
2016/03/01 03:31:14
This is used in the call to matchFamilyStyleCharac
| |
| 154 } | |
| 155 | |
| 156 // LChar is unsigned, while matchFamilyStyleCharacter requires a plain c har*. | |
| 157 const LChar* fontDescriptionFamilyName = fontDescription.family().family ().characters8(); | |
| 158 const char* skiaFamilyName = reinterpret_cast<const char*>(fontDescripti onFamilyName); | |
|
eae
2016/02/29 23:11:26
Elsewhere we convert the family name to utf8 befor
Ilya Kulshin
2016/03/01 03:31:14
Oh, not sure how I missed that API. That works muc
| |
| 159 static_assert(sizeof(*fontDescriptionFamilyName) == sizeof(*skiaFamilyNa me), | |
| 160 "skiaFamilyName and fontDescriptionFamilyName must be same size"); | |
| 161 | |
| 162 SkTypeface* typeface = m_fontManager->matchFamilyStyleCharacter( | |
| 163 skiaFamilyName, fontDescription.skiaFontStyle(), &bcp47Locale, local eCount, character); | |
| 164 if (typeface) { | |
| 165 SkString skiaFamily; | |
| 166 typeface->getFamilyName(&skiaFamily); | |
| 167 FontFaceCreationParams createByFamily(AtomicString(skiaFamily.c_str( ))); | |
| 168 data = getFontPlatformData(fontDescription, createByFamily); | |
| 169 } | |
| 170 } | |
| 171 | |
| 142 // Last resort font list : PanUnicode. CJK fonts have a pretty | 172 // Last resort font list : PanUnicode. CJK fonts have a pretty |
| 143 // large repertoire. Eventually, we need to scan all the fonts | 173 // large repertoire. Eventually, we need to scan all the fonts |
| 144 // on the system to have a Firefox-like coverage. | 174 // on the system to have a Firefox-like coverage. |
| 145 // Make sure that all of them are lowercased. | 175 // Make sure that all of them are lowercased. |
| 146 const static wchar_t* const cjkFonts[] = { | 176 const static wchar_t* const cjkFonts[] = { |
| 147 L"arial unicode ms", | 177 L"arial unicode ms", |
| 148 L"ms pgothic", | 178 L"ms pgothic", |
| 149 L"simsun", | 179 L"simsun", |
| 150 L"gulim", | 180 L"gulim", |
| 151 L"pmingliu", | 181 L"pmingliu", |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 if (typefacesMatchesFamily(tf.get(), family)) { | 449 if (typefacesMatchesFamily(tf.get(), family)) { |
| 420 result->setMinSizeForSubpixel(minSizeForSubpixelForFont); | 450 result->setMinSizeForSubpixel(minSizeForSubpixelForFont); |
| 421 break; | 451 break; |
| 422 } | 452 } |
| 423 } | 453 } |
| 424 | 454 |
| 425 return result.release(); | 455 return result.release(); |
| 426 } | 456 } |
| 427 | 457 |
| 428 } // namespace blink | 458 } // namespace blink |
| OLD | NEW |