OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. | 2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. |
3 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com | 3 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com |
4 * Copyright (C) 2007 Holger Hans Peter Freyther | 4 * Copyright (C) 2007 Holger Hans Peter Freyther |
5 * Copyright (C) 2007 Pioneer Research Center USA, Inc. | 5 * Copyright (C) 2007 Pioneer Research Center USA, Inc. |
6 * Copyright (C) 2010, 2011 Brent Fulgham <bfulgham@webkit.org> | 6 * Copyright (C) 2010, 2011 Brent Fulgham <bfulgham@webkit.org> |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 27 matching lines...) Expand all Loading... |
38 #ifndef FontPlatformData_h | 38 #ifndef FontPlatformData_h |
39 #define FontPlatformData_h | 39 #define FontPlatformData_h |
40 | 40 |
41 #include "FontOrientation.h" | 41 #include "FontOrientation.h" |
42 #include "FontWidthVariant.h" | 42 #include "FontWidthVariant.h" |
43 | 43 |
44 #if PLATFORM(WIN) | 44 #if PLATFORM(WIN) |
45 #include "RefCountedGDIHandle.h" | 45 #include "RefCountedGDIHandle.h" |
46 #endif | 46 #endif |
47 | 47 |
48 #if USE(CAIRO) | |
49 #include <wtf/HashFunctions.h> | |
50 #include <cairo.h> | |
51 #endif | |
52 | |
53 #if OS(DARWIN) | 48 #if OS(DARWIN) |
54 OBJC_CLASS NSFont; | 49 OBJC_CLASS NSFont; |
55 | 50 |
56 typedef struct CGFont* CGFontRef; | 51 typedef struct CGFont* CGFontRef; |
57 typedef const struct __CTFont* CTFontRef; | 52 typedef const struct __CTFont* CTFontRef; |
58 | 53 |
59 #include <CoreFoundation/CFBase.h> | 54 #include <CoreFoundation/CFBase.h> |
60 #include <objc/objc-auto.h> | 55 #include <objc/objc-auto.h> |
61 #endif | 56 #endif |
62 | 57 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 #if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM) | 106 #if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM) |
112 FontPlatformData(CGFontRef, float size, bool syntheticBold, bool syntheticOb
lique, FontOrientation, FontWidthVariant); | 107 FontPlatformData(CGFontRef, float size, bool syntheticBold, bool syntheticOb
lique, FontOrientation, FontWidthVariant); |
113 #endif | 108 #endif |
114 #endif | 109 #endif |
115 #if PLATFORM(WIN) | 110 #if PLATFORM(WIN) |
116 FontPlatformData(HFONT, float size, bool syntheticBold, bool syntheticObliqu
e, bool useGDI); | 111 FontPlatformData(HFONT, float size, bool syntheticBold, bool syntheticObliqu
e, bool useGDI); |
117 #if USE(CG) | 112 #if USE(CG) |
118 FontPlatformData(HFONT, CGFontRef, float size, bool syntheticBold, bool synt
heticOblique, bool useGDI); | 113 FontPlatformData(HFONT, CGFontRef, float size, bool syntheticBold, bool synt
heticOblique, bool useGDI); |
119 #endif | 114 #endif |
120 #endif | 115 #endif |
121 #if USE(CAIRO) | |
122 FontPlatformData(cairo_font_face_t*, float size, bool bold, bool italic); | |
123 #endif | |
124 | 116 |
125 ~FontPlatformData(); | 117 ~FontPlatformData(); |
126 | 118 |
127 #if PLATFORM(WIN) | 119 #if PLATFORM(WIN) |
128 HFONT hfont() const { return m_font ? m_font->handle() : 0; } | 120 HFONT hfont() const { return m_font ? m_font->handle() : 0; } |
129 bool useGDI() const { return m_useGDI; } | 121 bool useGDI() const { return m_useGDI; } |
130 #elif OS(DARWIN) | 122 #elif OS(DARWIN) |
131 NSFont* font() const { return m_font; } | 123 NSFont* font() const { return m_font; } |
132 void setFont(NSFont*); | 124 void setFont(NSFont*); |
133 #endif | 125 #endif |
(...skipping 18 matching lines...) Expand all Loading... |
152 bool isColorBitmapFont() const { return m_isColorBitmapFont; } | 144 bool isColorBitmapFont() const { return m_isColorBitmapFont; } |
153 bool isCompositeFontReference() const { return m_isCompositeFontReference; } | 145 bool isCompositeFontReference() const { return m_isCompositeFontReference; } |
154 #if OS(DARWIN) | 146 #if OS(DARWIN) |
155 bool isPrinterFont() const { return m_isPrinterFont; } | 147 bool isPrinterFont() const { return m_isPrinterFont; } |
156 #endif | 148 #endif |
157 FontOrientation orientation() const { return m_orientation; } | 149 FontOrientation orientation() const { return m_orientation; } |
158 FontWidthVariant widthVariant() const { return m_widthVariant; } | 150 FontWidthVariant widthVariant() const { return m_widthVariant; } |
159 | 151 |
160 void setOrientation(FontOrientation orientation) { m_orientation = orientati
on; } | 152 void setOrientation(FontOrientation orientation) { m_orientation = orientati
on; } |
161 | 153 |
162 #if USE(CAIRO) | |
163 cairo_scaled_font_t* scaledFont() const { return m_scaledFont; } | |
164 #endif | |
165 | |
166 #if PLATFORM(CHROMIUM) && OS(DARWIN) | 154 #if PLATFORM(CHROMIUM) && OS(DARWIN) |
167 HarfBuzzFace* harfBuzzFace(); | 155 HarfBuzzFace* harfBuzzFace(); |
168 #endif | 156 #endif |
169 | 157 |
170 unsigned hash() const | 158 unsigned hash() const |
171 { | 159 { |
172 #if PLATFORM(WIN) && !USE(CAIRO) | 160 #if PLATFORM(WIN) |
173 return m_font ? m_font->hash() : 0; | 161 return m_font ? m_font->hash() : 0; |
174 #elif OS(DARWIN) | 162 #elif OS(DARWIN) |
175 #if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM) | 163 #if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM) |
176 ASSERT(m_font || !m_cgFont); | 164 ASSERT(m_font || !m_cgFont); |
177 #endif | 165 #endif |
178 uintptr_t hashCodes[3] = { (uintptr_t)m_font, m_widthVariant, static_cas
t<uintptr_t>(m_isPrinterFont << 3 | m_orientation << 2 | m_syntheticBold << 1 |
m_syntheticOblique) }; | 166 uintptr_t hashCodes[3] = { (uintptr_t)m_font, m_widthVariant, static_cas
t<uintptr_t>(m_isPrinterFont << 3 | m_orientation << 2 | m_syntheticBold << 1 |
m_syntheticOblique) }; |
179 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes); | 167 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes); |
180 #elif USE(CAIRO) | |
181 return PtrHash<cairo_scaled_font_t*>::hash(m_scaledFont); | |
182 #endif | 168 #endif |
183 } | 169 } |
184 | 170 |
185 const FontPlatformData& operator=(const FontPlatformData&); | 171 const FontPlatformData& operator=(const FontPlatformData&); |
186 | 172 |
187 bool operator==(const FontPlatformData& other) const | 173 bool operator==(const FontPlatformData& other) const |
188 { | 174 { |
189 return platformIsEqual(other) | 175 return platformIsEqual(other) |
190 && m_size == other.m_size | 176 && m_size == other.m_size |
191 && m_syntheticBold == other.m_syntheticBold | 177 && m_syntheticBold == other.m_syntheticBold |
192 && m_syntheticOblique == other.m_syntheticOblique | 178 && m_syntheticOblique == other.m_syntheticOblique |
193 && m_isColorBitmapFont == other.m_isColorBitmapFont | 179 && m_isColorBitmapFont == other.m_isColorBitmapFont |
194 && m_isCompositeFontReference == other.m_isCompositeFontReference | 180 && m_isCompositeFontReference == other.m_isCompositeFontReference |
195 #if OS(DARWIN) | 181 #if OS(DARWIN) |
196 && m_isPrinterFont == other.m_isPrinterFont | 182 && m_isPrinterFont == other.m_isPrinterFont |
197 #endif | 183 #endif |
198 && m_orientation == other.m_orientation | 184 && m_orientation == other.m_orientation |
199 && m_widthVariant == other.m_widthVariant; | 185 && m_widthVariant == other.m_widthVariant; |
200 } | 186 } |
201 | 187 |
202 bool isHashTableDeletedValue() const | 188 bool isHashTableDeletedValue() const |
203 { | 189 { |
204 #if PLATFORM(WIN) && !USE(CAIRO) | 190 #if PLATFORM(WIN) |
205 return m_font.isHashTableDeletedValue(); | 191 return m_font.isHashTableDeletedValue(); |
206 #elif OS(DARWIN) | 192 #elif OS(DARWIN) |
207 return m_font == hashTableDeletedFontValue(); | 193 return m_font == hashTableDeletedFontValue(); |
208 #elif USE(CAIRO) | |
209 return m_scaledFont == hashTableDeletedFontValue(); | |
210 #endif | 194 #endif |
211 } | 195 } |
212 | 196 |
213 #if PLATFORM(WIN) && (USE(CG) || USE(CAIRO)) | 197 #if PLATFORM(WIN) && USE(CG) |
214 PassRefPtr<SharedBuffer> openTypeTable(uint32_t table) const; | 198 PassRefPtr<SharedBuffer> openTypeTable(uint32_t table) const; |
215 #endif | 199 #endif |
216 | 200 |
217 #ifndef NDEBUG | 201 #ifndef NDEBUG |
218 String description() const; | 202 String description() const; |
219 #endif | 203 #endif |
220 | 204 |
221 private: | 205 private: |
222 bool platformIsEqual(const FontPlatformData&) const; | 206 bool platformIsEqual(const FontPlatformData&) const; |
223 void platformDataInit(const FontPlatformData&); | 207 void platformDataInit(const FontPlatformData&); |
224 const FontPlatformData& platformDataAssign(const FontPlatformData&); | 208 const FontPlatformData& platformDataAssign(const FontPlatformData&); |
225 #if OS(DARWIN) | 209 #if OS(DARWIN) |
226 // Load various data about the font specified by |nsFont| with the size font
Size into the following output paramters: | 210 // Load various data about the font specified by |nsFont| with the size font
Size into the following output paramters: |
227 // Note: Callers should always take into account that for the Chromium port,
|outNSFont| isn't necessarily the same | 211 // Note: Callers should always take into account that for the Chromium port,
|outNSFont| isn't necessarily the same |
228 // font as |nsFont|. This because the sandbox may block loading of the origi
nal font. | 212 // font as |nsFont|. This because the sandbox may block loading of the origi
nal font. |
229 // * outNSFont - The font that was actually loaded, for the Chromium port th
is may be different than nsFont. | 213 // * outNSFont - The font that was actually loaded, for the Chromium port th
is may be different than nsFont. |
230 // The caller is responsible for calling CFRelease() on this parameter when
done with it. | 214 // The caller is responsible for calling CFRelease() on this parameter when
done with it. |
231 // * cgFont - CGFontRef representing the input font at the specified point s
ize. | 215 // * cgFont - CGFontRef representing the input font at the specified point s
ize. |
232 void loadFont(NSFont*, float fontSize, NSFont*& outNSFont, CGFontRef&); | 216 void loadFont(NSFont*, float fontSize, NSFont*& outNSFont, CGFontRef&); |
233 static NSFont* hashTableDeletedFontValue() { return reinterpret_cast<NSFont
*>(-1); } | 217 static NSFont* hashTableDeletedFontValue() { return reinterpret_cast<NSFont
*>(-1); } |
234 #elif PLATFORM(WIN) | 218 #elif PLATFORM(WIN) |
235 void platformDataInit(HFONT, float size, HDC, WCHAR* faceName); | 219 void platformDataInit(HFONT, float size, HDC, WCHAR* faceName); |
236 #endif | 220 #endif |
237 | 221 |
238 #if USE(CAIRO) | |
239 static cairo_scaled_font_t* hashTableDeletedFontValue() { return reinterpret
_cast<cairo_scaled_font_t*>(-1); } | |
240 #endif | |
241 | |
242 public: | 222 public: |
243 bool m_syntheticBold; | 223 bool m_syntheticBold; |
244 bool m_syntheticOblique; | 224 bool m_syntheticOblique; |
245 FontOrientation m_orientation; | 225 FontOrientation m_orientation; |
246 float m_size; | 226 float m_size; |
247 FontWidthVariant m_widthVariant; | 227 FontWidthVariant m_widthVariant; |
248 | 228 |
249 private: | 229 private: |
250 #if OS(DARWIN) | 230 #if OS(DARWIN) |
251 NSFont* m_font; | 231 NSFont* m_font; |
252 #elif PLATFORM(WIN) | 232 #elif PLATFORM(WIN) |
253 RefPtr<RefCountedGDIHandle<HFONT> > m_font; | 233 RefPtr<RefCountedGDIHandle<HFONT> > m_font; |
254 #endif | 234 #endif |
255 | 235 |
256 #if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM) | 236 #if USE(CG) || USE(SKIA_ON_MAC_CHROMIUM) |
257 #if PLATFORM(WIN) | 237 #if PLATFORM(WIN) |
258 RetainPtr<CGFontRef> m_cgFont; | 238 RetainPtr<CGFontRef> m_cgFont; |
259 #else | 239 #else |
260 RetainPtr<CGFontRef> m_cgFont; | 240 RetainPtr<CGFontRef> m_cgFont; |
261 mutable RetainPtr<CTFontRef> m_CTFont; | 241 mutable RetainPtr<CTFontRef> m_CTFont; |
262 #endif | 242 #endif |
263 #endif | 243 #endif |
264 | 244 |
265 #if USE(CAIRO) | |
266 cairo_scaled_font_t* m_scaledFont; | |
267 #endif | |
268 | |
269 #if PLATFORM(CHROMIUM) && OS(DARWIN) | 245 #if PLATFORM(CHROMIUM) && OS(DARWIN) |
270 RefPtr<MemoryActivatedFont> m_inMemoryFont; | 246 RefPtr<MemoryActivatedFont> m_inMemoryFont; |
271 RefPtr<HarfBuzzFace> m_harfBuzzFace; | 247 RefPtr<HarfBuzzFace> m_harfBuzzFace; |
272 #endif | 248 #endif |
273 | 249 |
274 bool m_isColorBitmapFont; | 250 bool m_isColorBitmapFont; |
275 bool m_isCompositeFontReference; | 251 bool m_isCompositeFontReference; |
276 #if OS(DARWIN) | 252 #if OS(DARWIN) |
277 bool m_isPrinterFont; | 253 bool m_isPrinterFont; |
278 #endif | 254 #endif |
279 | 255 |
280 #if PLATFORM(WIN) | 256 #if PLATFORM(WIN) |
281 bool m_useGDI; | 257 bool m_useGDI; |
282 #endif | 258 #endif |
283 }; | 259 }; |
284 | 260 |
285 } // namespace WebCore | 261 } // namespace WebCore |
286 | 262 |
287 #endif // FontPlatformData_h | 263 #endif // FontPlatformData_h |
288 | 264 |
289 #endif | 265 #endif |
OLD | NEW |