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

Unified Diff: third_party/WebKit/Source/platform/fonts/FontCache.cpp

Issue 2441343003: Allow the default generic font family settings to find the first available font (Closed)
Patch Set: msw review Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
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..1ac542a2c04fdca50461f0c8a3c724346acec6b4 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_list.h"
#include "wtf/HashMap.h"
#include "wtf/ListHashSet.h"
#include "wtf/PtrUtil.h"
@@ -303,6 +304,15 @@ bool FontCache::isPlatformFontAvailable(const FontDescription& fontDescription,
checkingAlternateName);
}
+String FontCache::firstAvailableOrFirst(const String& families) {
+ // The conversions involve at least two string copies, and more if non-ASCII.
+ // For now we prefer shared code over the cost because a) inputs are
+ // only from grd/xtb and all ASCII, and b) at most only a few times per
+ // setting change/script.
+ return String::fromUTF8(
+ gfx::FontList::FirstAvailableOrFirst(families.utf8().data()).c_str());
+}
+
SimpleFontData* FontCache::getNonRetainedLastResortFallbackFont(
const FontDescription& fontDescription) {
return getLastResortFallbackFont(fontDescription, DoNotRetain).leakRef();
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/FontCache.h ('k') | third_party/WebKit/Source/platform/fonts/FontCacheTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698