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

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, 10 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 73a82163e164ad8dad6d54c2359c3d087ab487d6..683e5dd536ff0b8f9e5510c79254f269c99c8abc 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;
@@ -52,6 +63,17 @@ void FontCache::getFontForCharacter(UChar32 c, const char* preferredLocale, Font
#if !OS(ANDROID)
PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescription& fontDescription, UChar32 c, const SimpleFontData*)
{
+ // 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);
+ if (familyName.isEmpty())
+ return getLastResortFallbackFont(fontDescription, DoNotRetain);
+ return fontDataFromFontPlatformData(getFontPlatformData(fontDescription, FontFaceCreationParams(familyName)), DoNotRetain);
+ }
+
// First try the specified font with standard style & weight.
if (fontDescription.style() == FontStyleItalic
|| fontDescription.weight() >= FontWeight600) {

Powered by Google App Engine
This is Rietveld 408576698