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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 16 matching lines...) Expand all
27 #include "platform/fonts/FontPlatformData.h" 27 #include "platform/fonts/FontPlatformData.h"
28 #include "platform/fonts/SimpleFontData.h" 28 #include "platform/fonts/SimpleFontData.h"
29 #include "public/platform/linux/WebFallbackFont.h" 29 #include "public/platform/linux/WebFallbackFont.h"
30 #include "public/platform/linux/WebFontInfo.h" 30 #include "public/platform/linux/WebFontInfo.h"
31 #include "public/platform/linux/WebSandboxSupport.h" 31 #include "public/platform/linux/WebSandboxSupport.h"
32 #include "public/platform/Platform.h" 32 #include "public/platform/Platform.h"
33 #include "wtf/text/CString.h" 33 #include "wtf/text/CString.h"
34 34
35 namespace blink { 35 namespace blink {
36 36
37 FontCache::FontCache()
38 : m_purgePreventCount(0)
39 {
40 if (s_fontManager) {
41 adopted(s_fontManager);
42 m_fontManager = s_fontManager;
43 } else {
44 m_fontManager = nullptr;
45 }
46 }
47
37 void FontCache::getFontForCharacter(UChar32 c, const char* preferredLocale, Font Cache::PlatformFallbackFont* fallbackFont) 48 void FontCache::getFontForCharacter(UChar32 c, const char* preferredLocale, Font Cache::PlatformFallbackFont* fallbackFont)
38 { 49 {
39 WebFallbackFont webFallbackFont; 50 WebFallbackFont webFallbackFont;
40 if (Platform::current()->sandboxSupport()) 51 if (Platform::current()->sandboxSupport())
41 Platform::current()->sandboxSupport()->getFallbackFontForCharacter(c, pr eferredLocale, &webFallbackFont); 52 Platform::current()->sandboxSupport()->getFallbackFontForCharacter(c, pr eferredLocale, &webFallbackFont);
42 else 53 else
43 WebFontInfo::fallbackFontForChar(c, preferredLocale, &webFallbackFont); 54 WebFontInfo::fallbackFontForChar(c, preferredLocale, &webFallbackFont);
44 fallbackFont->name = String::fromUTF8(CString(webFallbackFont.name)); 55 fallbackFont->name = String::fromUTF8(CString(webFallbackFont.name));
45 fallbackFont->filename = webFallbackFont.filename; 56 fallbackFont->filename = webFallbackFont.filename;
46 fallbackFont->fontconfigInterfaceId = webFallbackFont.fontconfigInterfaceId; 57 fallbackFont->fontconfigInterfaceId = webFallbackFont.fontconfigInterfaceId;
47 fallbackFont->ttcIndex = webFallbackFont.ttcIndex; 58 fallbackFont->ttcIndex = webFallbackFont.ttcIndex;
48 fallbackFont->isBold = webFallbackFont.isBold; 59 fallbackFont->isBold = webFallbackFont.isBold;
49 fallbackFont->isItalic = webFallbackFont.isItalic; 60 fallbackFont->isItalic = webFallbackFont.isItalic;
50 } 61 }
51 62
52 #if !OS(ANDROID) 63 #if !OS(ANDROID)
53 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescrip tion& fontDescription, UChar32 c, const SimpleFontData*) 64 PassRefPtr<SimpleFontData> FontCache::fallbackFontForCharacter(const FontDescrip tion& fontDescription, UChar32 c, const SimpleFontData*)
54 { 65 {
66 // The m_fontManager is set only if it was provided by the embedder with Web FontRendering::setSkiaFontManager. This is
67 // used to emulate android fonts on linux so we always request the family fr om the font manager and if none is found, we return
68 // the LastResort fallback font and avoid using FontCache::getFontForCharact er which would use sandbox support to
69 // query the underlying system for the font family.
70 if (m_fontManager) {
71 AtomicString familyName = getFamilyNameForCharacter(m_fontManager.get(), c, fontDescription);
72 if (familyName.isEmpty())
73 return getLastResortFallbackFont(fontDescription, DoNotRetain);
74 return fontDataFromFontPlatformData(getFontPlatformData(fontDescription, FontFaceCreationParams(familyName)), DoNotRetain);
75 }
76
55 // First try the specified font with standard style & weight. 77 // First try the specified font with standard style & weight.
56 if (fontDescription.style() == FontStyleItalic 78 if (fontDescription.style() == FontStyleItalic
57 || fontDescription.weight() >= FontWeight600) { 79 || fontDescription.weight() >= FontWeight600) {
58 RefPtr<SimpleFontData> fontData = fallbackOnStandardFontStyle( 80 RefPtr<SimpleFontData> fontData = fallbackOnStandardFontStyle(
59 fontDescription, c); 81 fontDescription, c);
60 if (fontData) 82 if (fontData)
61 return fontData; 83 return fontData;
62 } 84 }
63 85
64 FontCache::PlatformFallbackFont fallbackFont; 86 FontCache::PlatformFallbackFont fallbackFont;
(...skipping 28 matching lines...) Expand all
93 return nullptr; 115 return nullptr;
94 FontPlatformData platformData = FontPlatformData(*substitutePlatformData); 116 FontPlatformData platformData = FontPlatformData(*substitutePlatformData);
95 platformData.setSyntheticBold(shouldSetSyntheticBold); 117 platformData.setSyntheticBold(shouldSetSyntheticBold);
96 platformData.setSyntheticItalic(shouldSetSyntheticItalic); 118 platformData.setSyntheticItalic(shouldSetSyntheticItalic);
97 return fontDataFromFontPlatformData(&platformData, DoNotRetain); 119 return fontDataFromFontPlatformData(&platformData, DoNotRetain);
98 } 120 }
99 121
100 #endif // !OS(ANDROID) 122 #endif // !OS(ANDROID)
101 123
102 } // namespace blink 124 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698