OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2006, 2007, 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2006, 2007, 2008, 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "wtf/RefPtr.h" | 43 #include "wtf/RefPtr.h" |
44 #include "wtf/text/CString.h" | 44 #include "wtf/text/CString.h" |
45 #include "wtf/text/StringImpl.h" | 45 #include "wtf/text/StringImpl.h" |
46 | 46 |
47 #if OS(MACOSX) | 47 #if OS(MACOSX) |
48 OBJC_CLASS NSFont; | 48 OBJC_CLASS NSFont; |
49 | 49 |
50 typedef struct CGFont* CGFontRef; | 50 typedef struct CGFont* CGFontRef; |
51 typedef const struct __CTFont* CTFontRef; | 51 typedef const struct __CTFont* CTFontRef; |
52 | 52 |
53 #include "platform/fonts/mac/MemoryActivatedFont.h" | |
54 #include <CoreFoundation/CFBase.h> | |
55 #include <objc/objc-auto.h> | 53 #include <objc/objc-auto.h> |
56 | 54 |
57 inline CTFontRef toCTFontRef(NSFont *nsFont) { return reinterpret_cast<CTFontRef
>(nsFont); } | 55 inline CTFontRef toCTFontRef(NSFont *nsFont) { return reinterpret_cast<CTFontRef
>(nsFont); } |
58 #endif // OS(MACOSX) | 56 #endif // OS(MACOSX) |
59 | 57 |
60 class SkTypeface; | 58 class SkTypeface; |
61 typedef uint32_t SkFontID; | 59 typedef uint32_t SkFontID; |
62 | 60 |
63 namespace blink { | 61 namespace blink { |
64 | 62 |
65 class Font; | 63 class Font; |
66 class GraphicsContext; | 64 class GraphicsContext; |
67 class HarfBuzzFace; | 65 class HarfBuzzFace; |
68 | 66 |
69 class PLATFORM_EXPORT FontPlatformData { | 67 class PLATFORM_EXPORT FontPlatformData { |
70 public: | 68 public: |
71 // Used for deleted values in the font cache's hash tables. The hash table | 69 // Used for deleted values in the font cache's hash tables. The hash table |
72 // will create us with this structure, and it will compare other values | 70 // will create us with this structure, and it will compare other values |
73 // to this "Deleted" one. It expects the Deleted one to be differentiable | 71 // to this "Deleted" one. It expects the Deleted one to be differentiable |
74 // from the 0 one (created with the empty constructor), so we can't just | 72 // from the 0 one (created with the empty constructor), so we can't just |
75 // set everything to 0. | 73 // set everything to 0. |
76 FontPlatformData(WTF::HashTableDeletedValueType); | 74 FontPlatformData(WTF::HashTableDeletedValueType); |
77 FontPlatformData(); | 75 FontPlatformData(); |
78 FontPlatformData(const FontPlatformData&); | 76 FontPlatformData(const FontPlatformData&); |
79 FontPlatformData(float size, bool syntheticBold, bool syntheticItalic, FontO
rientation = Horizontal); | 77 FontPlatformData(float size, bool syntheticBold, bool syntheticItalic, FontO
rientation = Horizontal); |
80 FontPlatformData(const FontPlatformData& src, float textSize); | 78 FontPlatformData(const FontPlatformData& src, float textSize); |
81 #if OS(MACOSX) | 79 #if OS(MACOSX) |
82 FontPlatformData(NSFont*, float size, bool syntheticBold = false, bool synth
eticItalic = false, FontOrientation = Horizontal); | 80 FontPlatformData(NSFont*, float size, bool syntheticBold = false, bool synth
eticItalic = false, FontOrientation = Horizontal); |
83 FontPlatformData(CGFontRef, PassRefPtr<SkTypeface>, float size, bool synthet
icBold, bool syntheticOblique, FontOrientation); | 81 #endif |
84 #else | |
85 FontPlatformData(PassRefPtr<SkTypeface>, const char* name, float textSize, b
ool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal, bool subp
ixelTextPosition = defaultUseSubpixelPositioning()); | 82 FontPlatformData(PassRefPtr<SkTypeface>, const char* name, float textSize, b
ool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal, bool subp
ixelTextPosition = defaultUseSubpixelPositioning()); |
86 #endif | |
87 ~FontPlatformData(); | 83 ~FontPlatformData(); |
88 | 84 |
89 #if OS(MACOSX) | 85 #if OS(MACOSX) |
90 NSFont* font() const { return m_font; } | |
91 void setFont(NSFont*); | |
92 | |
93 CGFontRef cgFont() const { return m_cgFont.get(); } | |
94 CTFontRef ctFont() const; | 86 CTFontRef ctFont() const; |
95 | 87 CGFontRef cgFont() const; |
96 bool roundsGlyphAdvances() const; | |
97 bool allowsLigatures() const; | |
98 | |
99 bool isColorBitmapFont() const { return m_isColorBitmapFont; } | |
100 bool isCompositeFontReference() const { return m_isCompositeFontReference; } | |
101 #endif | 88 #endif |
102 | 89 |
103 String fontFamilyName() const; | 90 String fontFamilyName() const; |
104 float size() const { return m_textSize; } | 91 float size() const { return m_textSize; } |
105 bool isFixedPitch() const; | 92 bool isFixedPitch() const; |
106 bool syntheticBold() const { return m_syntheticBold; } | 93 bool syntheticBold() const { return m_syntheticBold; } |
107 bool syntheticItalic() const { return m_syntheticItalic; } | 94 bool syntheticItalic() const { return m_syntheticItalic; } |
108 | 95 |
109 SkTypeface* typeface() const; | 96 SkTypeface* typeface() const; |
110 HarfBuzzFace* harfBuzzFace() const; | 97 HarfBuzzFace* harfBuzzFace() const; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 int paintTextFlags() const { return m_paintTextFlags; } | 132 int paintTextFlags() const { return m_paintTextFlags; } |
146 #else | 133 #else |
147 static void setHinting(SkPaint::Hinting); | 134 static void setHinting(SkPaint::Hinting); |
148 static void setAutoHint(bool); | 135 static void setAutoHint(bool); |
149 static void setUseBitmaps(bool); | 136 static void setUseBitmaps(bool); |
150 static void setAntiAlias(bool); | 137 static void setAntiAlias(bool); |
151 static void setSubpixelRendering(bool); | 138 static void setSubpixelRendering(bool); |
152 #endif | 139 #endif |
153 | 140 |
154 private: | 141 private: |
| 142 bool static defaultUseSubpixelPositioning(); |
155 #if !OS(MACOSX) | 143 #if !OS(MACOSX) |
156 bool static defaultUseSubpixelPositioning(); | |
157 void querySystemForRenderStyle(bool useSkiaSubpixelPositioning); | 144 void querySystemForRenderStyle(bool useSkiaSubpixelPositioning); |
158 #else | |
159 // Load various data about the font specified by |nsFont| with the size font
Size into the following output paramters: | |
160 // Note: Callers should always take into account that for the Chromium port,
|outNSFont| isn't necessarily the same | |
161 // font as |nsFont|. This because the sandbox may block loading of the origi
nal font. | |
162 // * outNSFont - The font that was actually loaded, for the Chromium port th
is may be different than nsFont. | |
163 // The caller is responsible for calling CFRelease() on this parameter when
done with it. | |
164 // * cgFont - CGFontRef representing the input font at the specified point s
ize. | |
165 void loadFont(NSFont*, float fontSize, NSFont*& outNSFont, CGFontRef&); | |
166 void platformDataInit(const FontPlatformData&); | |
167 const FontPlatformData& platformDataAssign(const FontPlatformData&); | |
168 bool isAATFont(CTFontRef) const; | |
169 #endif | 145 #endif |
170 | 146 |
171 mutable RefPtr<SkTypeface> m_typeface; | 147 mutable RefPtr<SkTypeface> m_typeface; |
172 #if !OS(WIN) | 148 #if !OS(WIN) |
173 CString m_family; | 149 CString m_family; |
174 #endif | 150 #endif |
175 | 151 |
176 public: | 152 public: |
177 float m_textSize; | 153 float m_textSize; |
178 bool m_syntheticBold; | 154 bool m_syntheticBold; |
179 bool m_syntheticItalic; | 155 bool m_syntheticItalic; |
180 FontOrientation m_orientation; | 156 FontOrientation m_orientation; |
181 #if OS(MACOSX) | |
182 bool m_isColorBitmapFont; | |
183 bool m_isCompositeFontReference; | |
184 #endif | |
185 private: | 157 private: |
186 #if OS(MACOSX) | 158 #if !OS(MACOSX) |
187 NSFont* m_font; | |
188 RetainPtr<CGFontRef> m_cgFont; | |
189 mutable RetainPtr<CTFontRef> m_CTFont; | |
190 RefPtr<MemoryActivatedFont> m_inMemoryFont; | |
191 #else | |
192 FontRenderStyle m_style; | 159 FontRenderStyle m_style; |
193 #endif | 160 #endif |
194 | 161 |
195 mutable RefPtr<HarfBuzzFace> m_harfBuzzFace; | 162 mutable RefPtr<HarfBuzzFace> m_harfBuzzFace; |
196 bool m_isHashTableDeletedValue; | 163 bool m_isHashTableDeletedValue; |
197 #if OS(WIN) | 164 #if OS(WIN) |
198 int m_paintTextFlags; | 165 int m_paintTextFlags; |
199 bool m_useSubpixelPositioning; | 166 bool m_useSubpixelPositioning; |
200 unsigned m_minSizeForAntiAlias; | 167 unsigned m_minSizeForAntiAlias; |
201 float m_minSizeForSubpixel; | 168 float m_minSizeForSubpixel; |
202 #endif | 169 #endif |
203 }; | 170 }; |
204 | 171 |
205 } // namespace blink | 172 } // namespace blink |
206 | 173 |
207 #endif // ifdef FontPlatformData_h | 174 #endif // ifdef FontPlatformData_h |
OLD | NEW |