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

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: Rebase Created 4 years, 7 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 #if OS(LINUX) || OS(WIN) 186 #if OS(LINUX) || OS(WIN)
187 // On linux if the fontManager has been overridden then we should be calling the embedder 187 // On linux if the fontManager has been overridden then we should be calling the embedder
188 // provided font Manager rather than calling SkTypeface::CreateFromName whic h may redirect the 188 // provided font Manager rather than calling SkTypeface::CreateFromName whic h may redirect the
189 // call to the default font Manager. 189 // call to the default font Manager.
190 // On Windows the font manager is always present. 190 // On Windows the font manager is always present.
191 if (m_fontManager) 191 if (m_fontManager)
192 return adoptRef(m_fontManager->matchFamilyStyle(name.data(), fontDescrip tion.skiaFontStyle())); 192 return adoptRef(m_fontManager->matchFamilyStyle(name.data(), fontDescrip tion.skiaFontStyle()));
193 #endif 193 #endif
194 194
195 // FIXME: Use m_fontManager, SkFontStyle and matchFamilyStyle instead of 195 // FIXME: Use m_fontManager, matchFamilyStyle instead of
196 // CreateFromName on all platforms. 196 // legacyCreateTypeface on all platforms.
197 int style = SkTypeface::kNormal; 197 RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault());
198 if (fontDescription.weight() >= FontWeight600) 198 return adoptRef(fm->legacyCreateTypeface(name.data(),
199 style |= SkTypeface::kBold; 199 fontDescription.skiaFontStyle()));
200 if (fontDescription.style())
201 style |= SkTypeface::kItalic;
202 return adoptRef(SkTypeface::CreateFromName(name.data(), static_cast<SkTypefa ce::Style>(style)));
203 } 200 }
204 201
205 #if !OS(WIN) 202 #if !OS(WIN)
206 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip tion& fontDescription, 203 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip tion& fontDescription,
207 const FontFaceCreationParams& creationParams, float fontSize) 204 const FontFaceCreationParams& creationParams, float fontSize)
208 { 205 {
209 CString name; 206 CString name;
210 RefPtr<SkTypeface> tf(createTypeface(fontDescription, creationParams, name)) ; 207 RefPtr<SkTypeface> tf(createTypeface(fontDescription, creationParams, name)) ;
211 if (!tf) 208 if (!tf)
212 return nullptr; 209 return nullptr;
213 210
214 return adoptPtr(new FontPlatformData(tf, 211 return adoptPtr(new FontPlatformData(tf,
215 name.data(), 212 name.data(),
216 fontSize, 213 fontSize,
217 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc ription.isSyntheticBold(), 214 (fontDescription.weight() > 200 + tf->fontStyle().weight()) || fontDescr iption.isSyntheticBold(),
218 ((fontDescription.style() == FontStyleItalic || fontDescription.style() == FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(), 215 ((fontDescription.style() == FontStyleItalic || fontDescription.style() == FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(),
219 fontDescription.orientation())); 216 fontDescription.orientation()));
220 } 217 }
221 #endif // !OS(WIN) 218 #endif // !OS(WIN)
222 219
223 } // namespace blink 220 } // 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