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

Side by Side Diff: Source/platform/fonts/FontCache.h

Issue 307243002: Fix font family based fallback font selection (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Windows link fix. Created 6 years, 6 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
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/platform/fonts/FontCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2008 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006, 2008 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2007-2008 Torch Mobile, Inc. 3 * Copyright (C) 2007-2008 Torch Mobile, Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 14 matching lines...) Expand all
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30 #ifndef FontCache_h 30 #ifndef FontCache_h
31 #define FontCache_h 31 #define FontCache_h
32 32
33 #include <limits.h> 33 #include <limits.h>
34 #include "platform/PlatformExport.h" 34 #include "platform/PlatformExport.h"
35 #include "platform/fonts/FontFaceCreationParams.h"
35 #include "wtf/Forward.h" 36 #include "wtf/Forward.h"
36 #include "wtf/HashMap.h" 37 #include "wtf/HashMap.h"
37 #include "wtf/PassRefPtr.h" 38 #include "wtf/PassRefPtr.h"
38 #include "wtf/RefPtr.h" 39 #include "wtf/RefPtr.h"
39 #include "wtf/Vector.h" 40 #include "wtf/Vector.h"
40 #include "wtf/text/CString.h" 41 #include "wtf/text/CString.h"
41 #include "wtf/text/WTFString.h" 42 #include "wtf/text/WTFString.h"
42 #include "wtf/unicode/Unicode.h" 43 #include "wtf/unicode/Unicode.h"
43 44
44 #if OS(WIN) 45 #if OS(WIN)
45 #include "SkFontMgr.h" 46 #include "SkFontMgr.h"
46 #include <windows.h> 47 #include <windows.h>
47 #include <objidl.h> 48 #include <objidl.h>
48 #include <mlang.h> 49 #include <mlang.h>
49 struct IDWriteFactory; 50 struct IDWriteFactory;
50 #endif 51 #endif
51 52
52 #if OS(ANDROID) 53 #if OS(ANDROID)
53 #include <unicode/uscript.h> 54 #include <unicode/uscript.h>
54 #endif 55 #endif
55 56
56 class SkTypeface; 57 class SkTypeface;
57 58
58 namespace WebCore { 59 namespace WebCore {
59 60
60 class FontCacheClient; 61 class FontCacheClient;
62 class FontFaceCreationParams;
61 class FontPlatformData; 63 class FontPlatformData;
62 class FontData; 64 class FontData;
63 class FontDescription; 65 class FontDescription;
64 class OpenTypeVerticalData; 66 class OpenTypeVerticalData;
65 class SimpleFontData; 67 class SimpleFontData;
66 68
67 enum ShouldRetain { Retain, DoNotRetain }; 69 enum ShouldRetain { Retain, DoNotRetain };
68 enum PurgeSeverity { PurgeIfNeeded, ForcePurge }; 70 enum PurgeSeverity { PurgeIfNeeded, ForcePurge };
69 71
70 class PLATFORM_EXPORT FontCache { 72 class PLATFORM_EXPORT FontCache {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 typedef uint32_t FontFileKey; 116 typedef uint32_t FontFileKey;
115 PassRefPtr<OpenTypeVerticalData> getVerticalData(const FontFileKey&, const F ontPlatformData&); 117 PassRefPtr<OpenTypeVerticalData> getVerticalData(const FontFileKey&, const F ontPlatformData&);
116 #endif 118 #endif
117 119
118 #if OS(ANDROID) 120 #if OS(ANDROID)
119 static AtomicString getGenericFamilyNameForScript(const AtomicString& family Name, UScriptCode); 121 static AtomicString getGenericFamilyNameForScript(const AtomicString& family Name, UScriptCode);
120 #else 122 #else
121 struct PlatformFallbackFont { 123 struct PlatformFallbackFont {
122 String name; 124 String name;
123 CString filename; 125 CString filename;
126 int fontconfigInterfaceId;
124 int ttcIndex; 127 int ttcIndex;
125 bool isBold; 128 bool isBold;
126 bool isItalic; 129 bool isItalic;
127 }; 130 };
128 static void getFontForCharacter(UChar32, const char* preferredLocale, Platfo rmFallbackFont*); 131 static void getFontForCharacter(UChar32, const char* preferredLocale, Platfo rmFallbackFont*);
129 #endif 132 #endif
130 133
131 private: 134 private:
132 FontCache(); 135 FontCache();
133 ~FontCache(); 136 ~FontCache();
134 137
135 void purge(PurgeSeverity = PurgeIfNeeded); 138 void purge(PurgeSeverity = PurgeIfNeeded);
136 139
137 void disablePurging() { m_purgePreventCount++; } 140 void disablePurging() { m_purgePreventCount++; }
138 void enablePurging() 141 void enablePurging()
139 { 142 {
140 ASSERT(m_purgePreventCount); 143 ASSERT(m_purgePreventCount);
141 if (!--m_purgePreventCount) 144 if (!--m_purgePreventCount)
142 purge(PurgeIfNeeded); 145 purge(PurgeIfNeeded);
143 } 146 }
144 147
145 // FIXME: This method should eventually be removed. 148 // FIXME: This method should eventually be removed.
146 FontPlatformData* getFontPlatformData(const FontDescription&, const AtomicSt ring& family, bool checkingAlternateName = false); 149 FontPlatformData* getFontPlatformData(const FontDescription&, const FontFace CreationParams&, bool checkingAlternateName = false);
147 150
148 // These methods are implemented by each platform. 151 // These methods are implemented by each platform.
149 FontPlatformData* createFontPlatformData(const FontDescription&, const Atomi cString& family, float fontSize); 152 FontPlatformData* createFontPlatformData(const FontDescription&, const FontF aceCreationParams&, float fontSize);
150 153
151 // Implemented on skia platforms. 154 // Implemented on skia platforms.
152 PassRefPtr<SkTypeface> createTypeface(const FontDescription&, const AtomicSt ring& family, CString& name); 155 PassRefPtr<SkTypeface> createTypeface(const FontDescription&, const FontFace CreationParams&, CString& name);
153 156
154 PassRefPtr<SimpleFontData> fontDataFromFontPlatformData(const FontPlatformDa ta*, ShouldRetain = Retain); 157 PassRefPtr<SimpleFontData> fontDataFromFontPlatformData(const FontPlatformDa ta*, ShouldRetain = Retain);
155 158
156 // Don't purge if this count is > 0; 159 // Don't purge if this count is > 0;
157 int m_purgePreventCount; 160 int m_purgePreventCount;
158 161
159 #if OS(WIN) 162 #if OS(WIN)
160 OwnPtr<SkFontMgr> m_fontManager; 163 OwnPtr<SkFontMgr> m_fontManager;
161 static bool s_useDirectWrite; 164 static bool s_useDirectWrite;
162 static IDWriteFactory* s_directWriteFactory; 165 static IDWriteFactory* s_directWriteFactory;
(...skipping 10 matching lines...) Expand all
173 176
174 class PLATFORM_EXPORT FontCachePurgePreventer { 177 class PLATFORM_EXPORT FontCachePurgePreventer {
175 public: 178 public:
176 FontCachePurgePreventer() { FontCache::fontCache()->disablePurging(); } 179 FontCachePurgePreventer() { FontCache::fontCache()->disablePurging(); }
177 ~FontCachePurgePreventer() { FontCache::fontCache()->enablePurging(); } 180 ~FontCachePurgePreventer() { FontCache::fontCache()->enablePurging(); }
178 }; 181 };
179 182
180 } 183 }
181 184
182 #endif 185 #endif
OLDNEW
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/platform/fonts/FontCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698