OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 Google Inc. All rights reserved. | 2 * Copyright (c) 2011 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 21 matching lines...) Expand all Loading... |
32 | 32 |
33 #include "platform/Language.h" | 33 #include "platform/Language.h" |
34 #include "platform/fonts/SimpleFontData.h" | 34 #include "platform/fonts/SimpleFontData.h" |
35 #include "platform/fonts/FontDescription.h" | 35 #include "platform/fonts/FontDescription.h" |
36 #include "platform/fonts/FontFaceCreationParams.h" | 36 #include "platform/fonts/FontFaceCreationParams.h" |
37 #include "third_party/skia/include/core/SkTypeface.h" | 37 #include "third_party/skia/include/core/SkTypeface.h" |
38 #include "third_party/skia/include/ports/SkFontMgr.h" | 38 #include "third_party/skia/include/ports/SkFontMgr.h" |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
| 42 static AtomicString defaultFontFamily(SkFontMgr* fontManager) { |
| 43 sk_sp<SkTypeface> typeface( |
| 44 fontManager->legacyCreateTypeface(nullptr, SkFontStyle())); |
| 45 SkString familyName; |
| 46 typeface->getFamilyName(&familyName); |
| 47 return familyName.c_str(); |
| 48 } |
| 49 |
| 50 static AtomicString defaultFontFamily() { |
| 51 if (SkFontMgr* fontManager = FontCache::fontCache()->fontManager()) |
| 52 return defaultFontFamily(fontManager); |
| 53 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); |
| 54 return defaultFontFamily(fm.get()); |
| 55 } |
| 56 |
| 57 // static |
| 58 const AtomicString& FontCache::systemFontFamily() { |
| 59 DEFINE_STATIC_LOCAL(AtomicString, systemFontFamily, (defaultFontFamily())); |
| 60 return systemFontFamily; |
| 61 } |
| 62 |
42 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter( | 63 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter( |
43 const FontDescription& fontDescription, | 64 const FontDescription& fontDescription, |
44 UChar32 c, | 65 UChar32 c, |
45 const SimpleFontData*, | 66 const SimpleFontData*, |
46 FontFallbackPriority fallbackPriority) { | 67 FontFallbackPriority fallbackPriority) { |
47 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); | 68 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); |
48 AtomicString familyName = | 69 AtomicString familyName = |
49 getFamilyNameForCharacter(fm.get(), c, fontDescription, fallbackPriority); | 70 getFamilyNameForCharacter(fm.get(), c, fontDescription, fallbackPriority); |
50 if (familyName.isEmpty()) | 71 if (familyName.isEmpty()) |
51 return getLastResortFallbackFont(fontDescription, DoNotRetain); | 72 return getLastResortFallbackFont(fontDescription, DoNotRetain); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // For other scripts, use the default generic family mapping logic. | 111 // For other scripts, use the default generic family mapping logic. |
91 return familyName; | 112 return familyName; |
92 } | 113 } |
93 | 114 |
94 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); | 115 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); |
95 return getFamilyNameForCharacter(fm.get(), examplerChar, fontDescription, | 116 return getFamilyNameForCharacter(fm.get(), examplerChar, fontDescription, |
96 FontFallbackPriority::Text); | 117 FontFallbackPriority::Text); |
97 } | 118 } |
98 | 119 |
99 } // namespace blink | 120 } // namespace blink |
OLD | NEW |