| Index: third_party/WebKit/Source/platform/fonts/FontCache.cpp
|
| diff --git a/third_party/WebKit/Source/platform/fonts/FontCache.cpp b/third_party/WebKit/Source/platform/fonts/FontCache.cpp
|
| index 2844a92e37aa811a9dd023d1d65441be65a5e5da..a4b1de73bb7d398008ad5d7a195cf7684834c4ec 100644
|
| --- a/third_party/WebKit/Source/platform/fonts/FontCache.cpp
|
| +++ b/third_party/WebKit/Source/platform/fonts/FontCache.cpp
|
| @@ -48,6 +48,7 @@
|
| #include "platform/tracing/web_memory_allocator_dump.h"
|
| #include "platform/tracing/web_process_memory_dump.h"
|
| #include "public/platform/Platform.h"
|
| +#include "ui/gfx/font.h"
|
| #include "wtf/HashMap.h"
|
| #include "wtf/ListHashSet.h"
|
| #include "wtf/PtrUtil.h"
|
| @@ -302,6 +303,31 @@ bool FontCache::isPlatformFontAvailable(const FontDescription& fontDescription,
|
| FontFaceCreationParams(adjustFamilyNameToAvoidUnsupportedFonts(family)),
|
| checkingAlternateName);
|
| }
|
| +static bool isFontFamilyAvailable(const String& family,
|
| + SkFontMgr* fontManager) {
|
| +#if OS(LINUX)
|
| + sk_sp<SkTypeface> typeface(
|
| + fontManager->legacyCreateTypeface(family.utf8().data(), SkFontStyle()));
|
| + return typeface;
|
| +#else
|
| + sk_sp<SkFontStyleSet> set(fontManager->matchFamily(family.utf8().data()));
|
| + return set && set->count();
|
| +#endif
|
| +}
|
| +
|
| +String FontCache::firstAvailableOrFirst(const String& families) {
|
| + Vector<String> familyList;
|
| + families.split(',', familyList);
|
| + if (familyList.isEmpty())
|
| + return String();
|
| + sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
|
| + for (String& family : familyList) {
|
| + family = family.stripWhiteSpace();
|
| + if (isFontFamilyAvailable(family, fm.get()))
|
| + return family;
|
| + }
|
| + return familyList.first();
|
| +}
|
|
|
| SimpleFontData* FontCache::getNonRetainedLastResortFallbackFont(
|
| const FontDescription& fontDescription) {
|
|
|