OLD | NEW |
---|---|
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 #endif | 190 #endif |
191 | 191 |
192 #if OS(LINUX) | 192 #if OS(LINUX) |
193 // On linux if the fontManager has been overridden then we should be calling the embedder | 193 // On linux if the fontManager has been overridden then we should be calling the embedder |
194 // provided font Manager rather than calling SkTypeface::CreateFromName whic h may redirect the | 194 // provided font Manager rather than calling SkTypeface::CreateFromName whic h may redirect the |
195 // call to the default font Manager. | 195 // call to the default font Manager. |
196 if (m_fontManager) | 196 if (m_fontManager) |
197 return adoptRef(m_fontManager->matchFamilyStyle(name.data(), fontDescrip tion.skiaFontStyle())); | 197 return adoptRef(m_fontManager->matchFamilyStyle(name.data(), fontDescrip tion.skiaFontStyle())); |
198 #endif | 198 #endif |
199 | 199 |
200 // FIXME: Use m_fontManager, SkFontStyle and matchFamilyStyle instead of | 200 // FIXME: Use m_fontManager, matchFamilyStyle instead of |
201 // CreateFromName on all platforms. | 201 // legacyCreateTypeface on all platforms. |
202 int style = SkTypeface::kNormal; | 202 RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault()); |
203 if (fontDescription.weight() >= FontWeight600) | 203 return adoptRef(fm->legacyCreateTypeface(name.data(), |
204 style |= SkTypeface::kBold; | 204 fontDescription.skiaFontStyle())); |
205 if (fontDescription.style()) | |
206 style |= SkTypeface::kItalic; | |
bungeman-skia
2016/04/25 19:18:02
This or'ed in kItalic if the fontDescription was e
Tom (Use chromium acct)
2016/04/26 00:36:15
Done.
| |
207 return adoptRef(SkTypeface::CreateFromName(name.data(), static_cast<SkTypefa ce::Style>(style))); | |
208 } | 205 } |
209 | 206 |
210 #if !OS(WIN) | 207 #if !OS(WIN) |
211 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip tion& fontDescription, | 208 PassOwnPtr<FontPlatformData> FontCache::createFontPlatformData(const FontDescrip tion& fontDescription, |
212 const FontFaceCreationParams& creationParams, float fontSize) | 209 const FontFaceCreationParams& creationParams, float fontSize) |
213 { | 210 { |
214 CString name; | 211 CString name; |
215 RefPtr<SkTypeface> tf(createTypeface(fontDescription, creationParams, name)) ; | 212 RefPtr<SkTypeface> tf(createTypeface(fontDescription, creationParams, name)) ; |
216 if (!tf) | 213 if (!tf) |
217 return nullptr; | 214 return nullptr; |
218 | 215 |
219 return adoptPtr(new FontPlatformData(tf, | 216 return adoptPtr(new FontPlatformData(tf, |
220 name.data(), | 217 name.data(), |
221 fontSize, | 218 fontSize, |
222 (fontDescription.weight() >= FontWeight600 && !tf->isBold()) || fontDesc ription.isSyntheticBold(), | 219 (fontDescription.weight() > 200 + tf->fontStyle().weight()) || fontDescr iption.isSyntheticBold(), |
223 ((fontDescription.style() == FontStyleItalic || fontDescription.style() == FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(), | 220 ((fontDescription.style() == FontStyleItalic || fontDescription.style() == FontStyleOblique) && !tf->isItalic()) || fontDescription.isSyntheticItalic(), |
224 fontDescription.orientation(), | 221 fontDescription.orientation(), |
225 fontDescription.useSubpixelPositioning())); | 222 fontDescription.useSubpixelPositioning())); |
226 } | 223 } |
227 #endif // !OS(WIN) | 224 #endif // !OS(WIN) |
228 | 225 |
229 } // namespace blink | 226 } // namespace blink |
OLD | NEW |