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

Unified Diff: third_party/WebKit/Source/platform/fonts/linux/FontCacheLinux.cpp

Issue 1685053002: blink fonts: Load Android SkFontMgr on Linux. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@windows_change
Patch Set: Rebase. Created 4 years, 9 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/linux/FontCacheLinux.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/linux/FontCacheLinux.cpp b/third_party/WebKit/Source/platform/fonts/linux/FontCacheLinux.cpp
index 9dad8c839375728a68bd055471b03c0f9713a880..d881c69c6e1b78e37f7c3a874ae2ec1f4cf743e9 100644
--- a/third_party/WebKit/Source/platform/fonts/linux/FontCacheLinux.cpp
+++ b/third_party/WebKit/Source/platform/fonts/linux/FontCacheLinux.cpp
@@ -34,6 +34,17 @@
namespace blink {
+FontCache::FontCache()
+ : m_purgePreventCount(0)
+{
+ if (s_fontManager) {
+ adopted(s_fontManager);
+ m_fontManager = s_fontManager;
+ } else {
+ m_fontManager = nullptr;
+ }
+}
+
void FontCache::getFontForCharacter(UChar32 c, const char* preferredLocale, FontCache::PlatformFallbackFont* fallbackFont)
{
WebFallbackFont webFallbackFont;
@@ -56,6 +67,17 @@ PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(
const SimpleFontData*,
FontFallbackPriority fallbackPriority)
{
+ // The m_fontManager is set only if it was provided by the embedder with WebFontRendering::setSkiaFontManager. This is
+ // used to emulate android fonts on linux so we always request the family from the font manager and if none is found, we return
+ // the LastResort fallback font and avoid using FontCache::getFontForCharacter which would use sandbox support to
+ // query the underlying system for the font family.
+ if (m_fontManager) {
+ AtomicString familyName = getFamilyNameForCharacter(m_fontManager.get(), c, fontDescription, fallbackPriority);
+ if (familyName.isEmpty())
+ return getLastResortFallbackFont(fontDescription, DoNotRetain);
+ return fontDataFromFontPlatformData(getFontPlatformData(fontDescription, FontFaceCreationParams(familyName)), DoNotRetain);
+ }
+
if (fallbackPriority == FontFallbackPriority::EmojiEmoji) {
// FIXME crbug.com/591346: We're overriding the fallback character here
// with the FAMILY emoji in the hope to find a suitable emoji font.

Powered by Google App Engine
This is Rietveld 408576698