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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/skia/FontCacheSkia.cpp

Issue 1912013002: Use the new legacyCreateTypeface that has an SkFontStyle parameter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use the new legacyCreateTypeface that has an SkFontStyle paramete 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (c) 2006, 2007, 2008, 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 if (!fontPlatformData) { 164 if (!fontPlatformData) {
165 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, mssansserifCreationPar ams, (AtomicString("Microsoft Sans Serif"))); 165 DEFINE_STATIC_LOCAL(const FontFaceCreationParams, mssansserifCreationPar ams, (AtomicString("Microsoft Sans Serif")));
166 fontPlatformData = getFontPlatformData(description, mssansserifCreationP arams); 166 fontPlatformData = getFontPlatformData(description, mssansserifCreationP arams);
167 } 167 }
168 #endif 168 #endif
169 169
170 ASSERT(fontPlatformData); 170 ASSERT(fontPlatformData);
171 return fontDataFromFontPlatformData(fontPlatformData, shouldRetain); 171 return fontDataFromFontPlatformData(fontPlatformData, shouldRetain);
172 } 172 }
173 173
174 #if OS(WIN) || OS(LINUX) 174 #if OS(WIN) || OS(LINUX)
bungeman-skia 2016/04/22 18:42:28 You'll need to remove this ifdef block for Android
bungeman-skia 2016/04/22 18:44:49 I stated that poorly, the ifdef is no longer neede
Tom (Use chromium acct) 2016/04/22 18:51:53 Done.
Tom (Use chromium acct) 2016/04/22 18:51:53 Done.
175 static inline SkFontStyle fontStyle(const FontDescription& fontDescription) 175 static inline SkFontStyle fontStyle(const FontDescription& fontDescription)
176 { 176 {
177 int width = static_cast<int>(fontDescription.stretch()); 177 int width = static_cast<int>(fontDescription.stretch());
178 int weight = (fontDescription.weight() - FontWeight100 + 1) * 100; 178 int weight = (fontDescription.weight() - FontWeight100 + 1) * 100;
179 SkFontStyle::Slant slant = fontDescription.style() == FontStyleItalic 179 SkFontStyle::Slant slant = fontDescription.style() == FontStyleItalic
180 ? SkFontStyle::kItalic_Slant 180 ? SkFontStyle::kItalic_Slant
181 : SkFontStyle::kUpright_Slant; 181 : SkFontStyle::kUpright_Slant;
182 return SkFontStyle(weight, width, slant); 182 return SkFontStyle(weight, width, slant);
183 } 183 }
184 184
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 #endif 227 #endif
228 228
229 #if OS(LINUX) 229 #if OS(LINUX)
230 // On linux if the fontManager has been overridden then we should be calling the embedder 230 // On linux if the fontManager has been overridden then we should be calling the embedder
231 // provided font Manager rather than calling SkTypeface::CreateFromName whic h may redirect the 231 // provided font Manager rather than calling SkTypeface::CreateFromName whic h may redirect the
232 // call to the default font Manager. 232 // call to the default font Manager.
233 if (m_fontManager) 233 if (m_fontManager)
234 return adoptRef(m_fontManager->matchFamilyStyle(name.data(), fontStyle(f ontDescription))); 234 return adoptRef(m_fontManager->matchFamilyStyle(name.data(), fontStyle(f ontDescription)));
235 #endif 235 #endif
236 236
237 // FIXME: Use m_fontManager, SkFontStyle and matchFamilyStyle instead of 237 // FIXME: Use m_fontManager, matchFamilyStyle instead of
238 // CreateFromName on all platforms. 238 // legacyCreateTypeface on all platforms.
239 int style = SkTypeface::kNormal; 239 RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault());
240 if (fontDescription.weight() >= FontWeight600) 240 return adoptRef(fm->legacyCreateTypeface(name.data(),
241 style |= SkTypeface::kBold; 241 fontStyle(fontDescription)));
242 if (fontDescription.style())
243 style |= SkTypeface::kItalic;
244 return adoptRef(SkTypeface::CreateFromName(name.data(), static_cast<SkTypefa ce::Style>(style)));
245 } 242 }
246 243
247 #if !OS(WIN) 244 #if !OS(WIN)
248 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip tion& fontDescription, 245 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip tion& fontDescription,
249 const FontFaceCreationParams& creationParams, float fontSize) 246 const FontFaceCreationParams& creationParams, float fontSize)
250 { 247 {
251 CString name; 248 CString name;
252 RefPtr<SkTypeface> tf(createTypeface(fontDescription, creationParams, name)) ; 249 RefPtr<SkTypeface> tf(createTypeface(fontDescription, creationParams, name)) ;
253 if (!tf) 250 if (!tf)
254 return nullptr; 251 return nullptr;
255 252
256 return adoptPtr(new FontPlatformData(tf, 253 return adoptPtr(new FontPlatformData(tf,
257 name.data(), 254 name.data(),
258 fontSize, 255 fontSize,
259 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc ription.isSyntheticBold(), 256 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc ription.isSyntheticBold(),
260 ((fontDescription.style() == FontStyleItalic || fontDescription.style() == FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(), 257 ((fontDescription.style() == FontStyleItalic || fontDescription.style() == FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(),
261 fontDescription.orientation(), 258 fontDescription.orientation(),
262 fontDescription.useSubpixelPositioning())); 259 fontDescription.useSubpixelPositioning()));
263 } 260 }
264 #endif // !OS(WIN) 261 #endif // !OS(WIN)
265 262
266 } // namespace blink 263 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698