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

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

Issue 1877673002: Move legacyCreateTypeface to SkFontStyle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove DEPS change now that Skia change has landed. 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, 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 AtomicString family = creationParams.family(); 203 AtomicString family = creationParams.family();
204 // If we're creating a fallback font (e.g. "-webkit-monospace"), convert the name into 204 // If we're creating a fallback font (e.g. "-webkit-monospace"), convert the name into
205 // the fallback name (like "monospace") that fontconfig understands. 205 // the fallback name (like "monospace") that fontconfig understands.
206 if (!family.length() || family.startsWith("-webkit-")) { 206 if (!family.length() || family.startsWith("-webkit-")) {
207 name = getFallbackFontFamily(fontDescription).getString().utf8(); 207 name = getFallbackFontFamily(fontDescription).getString().utf8();
208 } else { 208 } else {
209 // convert the name to utf8 209 // convert the name to utf8
210 name = family.utf8(); 210 name = family.utf8();
211 } 211 }
212 212
213 int style = SkTypeface::kNormal;
214 if (fontDescription.weight() >= FontWeight600)
215 style |= SkTypeface::kBold;
216 if (fontDescription.style())
217 style |= SkTypeface::kItalic;
218
219 #if OS(WIN) 213 #if OS(WIN)
220 if (s_sideloadedFonts) { 214 if (s_sideloadedFonts) {
221 HashMap<String, RefPtr<SkTypeface>>::iterator sideloadedFont = 215 HashMap<String, RefPtr<SkTypeface>>::iterator sideloadedFont =
222 s_sideloadedFonts->find(name.data()); 216 s_sideloadedFonts->find(name.data());
223 if (sideloadedFont != s_sideloadedFonts->end()) 217 if (sideloadedFont != s_sideloadedFonts->end())
224 return sideloadedFont->value; 218 return sideloadedFont->value;
225 } 219 }
226 220
227 if (m_fontManager) { 221 if (m_fontManager) {
228 return adoptRef(useDirectWrite() 222 return adoptRef(useDirectWrite()
229 ? m_fontManager->matchFamilyStyle(name.data(), fontStyle(fontDescrip tion)) 223 ? m_fontManager->matchFamilyStyle(name.data(), fontStyle(fontDescrip tion))
230 : m_fontManager->legacyCreateTypeface(name.data(), style) 224 : m_fontManager->legacyCreateTypeface(name.data(), fontStyle(fontDes cription))
231 ); 225 );
232 } 226 }
233 #endif 227 #endif
234 228
235 #if OS(LINUX) 229 #if OS(LINUX)
236 // 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
237 // 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
238 // call to the default font Manager. 232 // call to the default font Manager.
239 if (m_fontManager) 233 if (m_fontManager)
240 return adoptRef(m_fontManager->matchFamilyStyle(name.data(), fontStyle(f ontDescription))); 234 return adoptRef(m_fontManager->matchFamilyStyle(name.data(), fontStyle(f ontDescription)));
241 #endif 235 #endif
242 236
243 // FIXME: Use m_fontManager, SkFontStyle and matchFamilyStyle instead of 237 // FIXME: Use m_fontManager, SkFontStyle and matchFamilyStyle instead of
244 // CreateFromName on all platforms. 238 // CreateFromName on all platforms.
239 int style = SkTypeface::kNormal;
240 if (fontDescription.weight() >= FontWeight600)
241 style |= SkTypeface::kBold;
242 if (fontDescription.style())
243 style |= SkTypeface::kItalic;
245 return adoptRef(SkTypeface::CreateFromName(name.data(), static_cast<SkTypefa ce::Style>(style))); 244 return adoptRef(SkTypeface::CreateFromName(name.data(), static_cast<SkTypefa ce::Style>(style)));
246 } 245 }
247 246
248 #if !OS(WIN) 247 #if !OS(WIN)
249 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip tion& fontDescription, 248 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip tion& fontDescription,
250 const FontFaceCreationParams& creationParams, float fontSize) 249 const FontFaceCreationParams& creationParams, float fontSize)
251 { 250 {
252 CString name; 251 CString name;
253 RefPtr<SkTypeface> tf(createTypeface(fontDescription, creationParams, name)) ; 252 RefPtr<SkTypeface> tf(createTypeface(fontDescription, creationParams, name)) ;
254 if (!tf) 253 if (!tf)
255 return nullptr; 254 return nullptr;
256 255
257 return adoptPtr(new FontPlatformData(tf, 256 return adoptPtr(new FontPlatformData(tf,
258 name.data(), 257 name.data(),
259 fontSize, 258 fontSize,
260 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc ription.isSyntheticBold(), 259 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc ription.isSyntheticBold(),
261 ((fontDescription.style() == FontStyleItalic || fontDescription.style() == FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(), 260 ((fontDescription.style() == FontStyleItalic || fontDescription.style() == FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(),
262 fontDescription.orientation(), 261 fontDescription.orientation(),
263 fontDescription.useSubpixelPositioning())); 262 fontDescription.useSubpixelPositioning()));
264 } 263 }
265 #endif // !OS(WIN) 264 #endif // !OS(WIN)
266 265
267 } // namespace blink 266 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698