Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: third_party/WebKit/Source/platform/fonts/win/FontCacheSkiaWin.cpp

Issue 1883483002: Add code to call skia's matchFamilyStyleCharacter API, which uses the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fallbackproxy
Patch Set: Add expectation for font-fallback failure on Win7 and revert DEPS change Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 fontDescription.locale(), 136 fontDescription.locale(),
136 &script, 137 &script,
137 fallbackPriority, 138 fallbackPriority,
138 m_fontManager.get()); 139 m_fontManager.get());
139 FontPlatformData* data = 0; 140 FontPlatformData* data = 0;
140 if (family) { 141 if (family) {
141 FontFaceCreationParams createByFamily(AtomicString(family, wcslen(family ))); 142 FontFaceCreationParams createByFamily(AtomicString(family, wcslen(family )));
142 data = getFontPlatformData(fontDescription, createByFamily); 143 data = getFontPlatformData(fontDescription, createByFamily);
143 } 144 }
144 145
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
145 // Last resort font list : PanUnicode. CJK fonts have a pretty 177 // Last resort font list : PanUnicode. CJK fonts have a pretty
146 // large repertoire. Eventually, we need to scan all the fonts 178 // large repertoire. Eventually, we need to scan all the fonts
147 // on the system to have a Firefox-like coverage. 179 // on the system to have a Firefox-like coverage.
148 // Make sure that all of them are lowercased. 180 // Make sure that all of them are lowercased.
149 const static wchar_t* const cjkFonts[] = { 181 const static wchar_t* const cjkFonts[] = {
150 L"arial unicode ms", 182 L"arial unicode ms",
151 L"ms pgothic", 183 L"ms pgothic",
152 L"simsun", 184 L"simsun",
153 L"gulim", 185 L"gulim",
154 L"pmingliu", 186 L"pmingliu",
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 if (typefacesMatchesFamily(tf.get(), family)) { 454 if (typefacesMatchesFamily(tf.get(), family)) {
423 result->setMinSizeForSubpixel(minSizeForSubpixelForFont); 455 result->setMinSizeForSubpixel(minSizeForSubpixelForFont);
424 break; 456 break;
425 } 457 }
426 } 458 }
427 459
428 return result.release(); 460 return result.release();
429 } 461 }
430 462
431 } // namespace blink 463 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698