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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 | 222 |
223 #if OS(WIN) | 223 #if OS(WIN) |
224 if (s_sideloadedFonts) { | 224 if (s_sideloadedFonts) { |
225 HashMap<String, sk_sp<SkTypeface>>::iterator sideloadedFont = | 225 HashMap<String, sk_sp<SkTypeface>>::iterator sideloadedFont = |
226 s_sideloadedFonts->find(name.data()); | 226 s_sideloadedFonts->find(name.data()); |
227 if (sideloadedFont != s_sideloadedFonts->end()) | 227 if (sideloadedFont != s_sideloadedFonts->end()) |
228 return sideloadedFont->value; | 228 return sideloadedFont->value; |
229 } | 229 } |
230 #endif | 230 #endif |
231 | 231 |
232 #if OS(WIN) | |
drott
2016/10/13 07:59:35
Okay, thanks for your explanations in the other pa
kojii
2016/10/13 09:03:20
Done in Blink. Sorry touching UI in browser is too
drott
2016/10/13 12:36:13
I'm reluctant to fallback to Skia's default font n
kojii
2016/10/13 13:37:59
Not only it's a lot of work for me, but also I don
drott
2016/10/13 16:45:13
In the document you're saying:
"ResourceBundle::G
kojii
2016/10/14 04:40:19
Can you elaborate your question more? On Linux, th
drott
2016/10/14 07:34:21
The phrasing in the document sounds to me like Ski
| |
233 DCHECK_NE(family, FontFamilyNames::system_ui); | |
234 const char* familyNameForSkia = name.data(); | |
235 #else | |
236 // When the system UI font is set by setSystemFontFamily(), "system-ui" should | |
237 // have been replaced to it in getFontPlatformData. Use the Skia default | |
238 // family if it is not set, to be consistent with our UI/menu rendering. | |
239 const char* familyNameForSkia = | |
240 family == FontFamilyNames::system_ui ? nullptr : name.data(); | |
241 #endif | |
242 | |
232 #if OS(LINUX) || OS(WIN) | 243 #if OS(LINUX) || OS(WIN) |
233 // On linux if the fontManager has been overridden then we should be calling | 244 // On linux if the fontManager has been overridden then we should be calling |
234 // the embedder provided font Manager rather than calling | 245 // the embedder provided font Manager rather than calling |
235 // SkTypeface::CreateFromName which may redirect the call to the default font | 246 // SkTypeface::CreateFromName which may redirect the call to the default font |
236 // Manager. On Windows the font manager is always present. | 247 // Manager. On Windows the font manager is always present. |
237 if (m_fontManager) | 248 if (m_fontManager) { |
238 return sk_sp<SkTypeface>(m_fontManager->matchFamilyStyle( | 249 return sk_sp<SkTypeface>(m_fontManager->matchFamilyStyle( |
239 name.data(), fontDescription.skiaFontStyle())); | 250 familyNameForSkia, fontDescription.skiaFontStyle())); |
251 } | |
240 #endif | 252 #endif |
241 | 253 |
242 // FIXME: Use m_fontManager, matchFamilyStyle instead of | 254 // FIXME: Use m_fontManager, matchFamilyStyle instead of |
243 // legacyCreateTypeface on all platforms. | 255 // legacyCreateTypeface on all platforms. |
244 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); | 256 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); |
245 return sk_sp<SkTypeface>( | 257 return sk_sp<SkTypeface>(fm->legacyCreateTypeface( |
246 fm->legacyCreateTypeface(name.data(), fontDescription.skiaFontStyle())); | 258 familyNameForSkia, fontDescription.skiaFontStyle())); |
247 } | 259 } |
248 | 260 |
249 #if !OS(WIN) | 261 #if !OS(WIN) |
250 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData( | 262 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData( |
251 const FontDescription& fontDescription, | 263 const FontDescription& fontDescription, |
252 const FontFaceCreationParams& creationParams, | 264 const FontFaceCreationParams& creationParams, |
253 float fontSize) { | 265 float fontSize) { |
254 CString name; | 266 CString name; |
255 sk_sp<SkTypeface> tf = createTypeface(fontDescription, creationParams, name); | 267 sk_sp<SkTypeface> tf = createTypeface(fontDescription, creationParams, name); |
256 if (!tf) | 268 if (!tf) |
257 return nullptr; | 269 return nullptr; |
258 | 270 |
259 return wrapUnique(new FontPlatformData( | 271 return wrapUnique(new FontPlatformData( |
260 tf, name.data(), fontSize, (numericFontWeight(fontDescription.weight()) > | 272 tf, name.data(), fontSize, (numericFontWeight(fontDescription.weight()) > |
261 200 + tf->fontStyle().weight()) || | 273 200 + tf->fontStyle().weight()) || |
262 fontDescription.isSyntheticBold(), | 274 fontDescription.isSyntheticBold(), |
263 ((fontDescription.style() == FontStyleItalic || | 275 ((fontDescription.style() == FontStyleItalic || |
264 fontDescription.style() == FontStyleOblique) && | 276 fontDescription.style() == FontStyleOblique) && |
265 !tf->isItalic()) || | 277 !tf->isItalic()) || |
266 fontDescription.isSyntheticItalic(), | 278 fontDescription.isSyntheticItalic(), |
267 fontDescription.orientation())); | 279 fontDescription.orientation())); |
268 } | 280 } |
269 #endif // !OS(WIN) | 281 #endif // !OS(WIN) |
270 | 282 |
271 } // namespace blink | 283 } // namespace blink |
OLD | NEW |