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> |
53 #include <objc/objc-auto.h> | 55 #include <objc/objc-auto.h> |
54 | 56 |
55 inline CTFontRef toCTFontRef(NSFont *nsFont) { return reinterpret_cast<CTFontRef
>(nsFont); } | 57 inline CTFontRef toCTFontRef(NSFont *nsFont) { return reinterpret_cast<CTFontRef
>(nsFont); } |
56 inline NSFont* toNSFont(CTFontRef ctFontRef) { return const_cast<NSFont*>(reinte
rpret_cast<const NSFont*>(ctFontRef)); } | |
57 #endif // OS(MACOSX) | 58 #endif // OS(MACOSX) |
58 | 59 |
59 class SkTypeface; | 60 class SkTypeface; |
60 typedef uint32_t SkFontID; | 61 typedef uint32_t SkFontID; |
61 | 62 |
62 namespace blink { | 63 namespace blink { |
63 | 64 |
64 class Font; | 65 class Font; |
65 class GraphicsContext; | 66 class GraphicsContext; |
66 class HarfBuzzFace; | 67 class HarfBuzzFace; |
67 | 68 |
68 class PLATFORM_EXPORT FontPlatformData { | 69 class PLATFORM_EXPORT FontPlatformData { |
69 public: | 70 public: |
70 // Used for deleted values in the font cache's hash tables. The hash table | 71 // Used for deleted values in the font cache's hash tables. The hash table |
71 // will create us with this structure, and it will compare other values | 72 // will create us with this structure, and it will compare other values |
72 // to this "Deleted" one. It expects the Deleted one to be differentiable | 73 // to this "Deleted" one. It expects the Deleted one to be differentiable |
73 // from the 0 one (created with the empty constructor), so we can't just | 74 // from the 0 one (created with the empty constructor), so we can't just |
74 // set everything to 0. | 75 // set everything to 0. |
75 FontPlatformData(WTF::HashTableDeletedValueType); | 76 FontPlatformData(WTF::HashTableDeletedValueType); |
76 FontPlatformData(); | 77 FontPlatformData(); |
77 FontPlatformData(const FontPlatformData&); | 78 FontPlatformData(const FontPlatformData&); |
78 FontPlatformData(float size, bool syntheticBold, bool syntheticItalic, FontO
rientation = Horizontal); | 79 FontPlatformData(float size, bool syntheticBold, bool syntheticItalic, FontO
rientation = Horizontal); |
79 FontPlatformData(const FontPlatformData& src, float textSize); | 80 FontPlatformData(const FontPlatformData& src, float textSize); |
80 #if OS(MACOSX) | 81 #if OS(MACOSX) |
81 FontPlatformData(NSFont*, float size, bool syntheticBold = false, bool synth
eticItalic = false, FontOrientation = Horizontal); | 82 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); |
| 84 #else |
| 85 FontPlatformData(PassRefPtr<SkTypeface>, const char* name, float textSize, b
ool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal, bool subp
ixelTextPosition = defaultUseSubpixelPositioning()); |
82 #endif | 86 #endif |
83 FontPlatformData(PassRefPtr<SkTypeface>, const char* name, float textSize, b
ool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal, bool subp
ixelTextPosition = defaultUseSubpixelPositioning()); | |
84 ~FontPlatformData(); | 87 ~FontPlatformData(); |
85 | 88 |
86 #if OS(MACOSX) | 89 #if OS(MACOSX) |
| 90 NSFont* font() const { return m_font; } |
| 91 void setFont(NSFont*); |
| 92 |
| 93 CGFontRef cgFont() const { return m_cgFont.get(); } |
87 CTFontRef ctFont() const; | 94 CTFontRef ctFont() const; |
88 CGFontRef cgFont() const; | 95 |
| 96 bool roundsGlyphAdvances() const; |
| 97 bool allowsLigatures() const; |
| 98 |
| 99 bool isColorBitmapFont() const { return m_isColorBitmapFont; } |
| 100 bool isCompositeFontReference() const { return m_isCompositeFontReference; } |
89 #endif | 101 #endif |
90 | 102 |
91 String fontFamilyName() const; | 103 String fontFamilyName() const; |
92 float size() const { return m_textSize; } | 104 float size() const { return m_textSize; } |
93 bool isFixedPitch() const; | 105 bool isFixedPitch() const; |
94 bool syntheticBold() const { return m_syntheticBold; } | 106 bool syntheticBold() const { return m_syntheticBold; } |
95 bool syntheticItalic() const { return m_syntheticItalic; } | 107 bool syntheticItalic() const { return m_syntheticItalic; } |
96 | 108 |
97 SkTypeface* typeface() const; | 109 SkTypeface* typeface() const; |
98 HarfBuzzFace* harfBuzzFace() const; | 110 HarfBuzzFace* harfBuzzFace() const; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 int paintTextFlags() const { return m_paintTextFlags; } | 145 int paintTextFlags() const { return m_paintTextFlags; } |
134 #else | 146 #else |
135 static void setHinting(SkPaint::Hinting); | 147 static void setHinting(SkPaint::Hinting); |
136 static void setAutoHint(bool); | 148 static void setAutoHint(bool); |
137 static void setUseBitmaps(bool); | 149 static void setUseBitmaps(bool); |
138 static void setAntiAlias(bool); | 150 static void setAntiAlias(bool); |
139 static void setSubpixelRendering(bool); | 151 static void setSubpixelRendering(bool); |
140 #endif | 152 #endif |
141 | 153 |
142 private: | 154 private: |
| 155 #if !OS(MACOSX) |
143 bool static defaultUseSubpixelPositioning(); | 156 bool static defaultUseSubpixelPositioning(); |
144 #if !OS(MACOSX) | |
145 void querySystemForRenderStyle(bool useSkiaSubpixelPositioning); | 157 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; |
146 #endif | 169 #endif |
147 | 170 |
148 mutable RefPtr<SkTypeface> m_typeface; | 171 mutable RefPtr<SkTypeface> m_typeface; |
149 #if !OS(WIN) | 172 #if !OS(WIN) |
150 CString m_family; | 173 CString m_family; |
151 #endif | 174 #endif |
152 | 175 |
153 public: | 176 public: |
154 float m_textSize; | 177 float m_textSize; |
155 bool m_syntheticBold; | 178 bool m_syntheticBold; |
156 bool m_syntheticItalic; | 179 bool m_syntheticItalic; |
157 FontOrientation m_orientation; | 180 FontOrientation m_orientation; |
| 181 #if OS(MACOSX) |
| 182 bool m_isColorBitmapFont; |
| 183 bool m_isCompositeFontReference; |
| 184 #endif |
158 private: | 185 private: |
159 #if !OS(MACOSX) | 186 #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 |
160 FontRenderStyle m_style; | 192 FontRenderStyle m_style; |
161 #endif | 193 #endif |
162 | 194 |
163 mutable RefPtr<HarfBuzzFace> m_harfBuzzFace; | 195 mutable RefPtr<HarfBuzzFace> m_harfBuzzFace; |
164 bool m_isHashTableDeletedValue; | 196 bool m_isHashTableDeletedValue; |
165 #if OS(WIN) | 197 #if OS(WIN) |
166 int m_paintTextFlags; | 198 int m_paintTextFlags; |
167 bool m_useSubpixelPositioning; | 199 bool m_useSubpixelPositioning; |
168 unsigned m_minSizeForAntiAlias; | 200 unsigned m_minSizeForAntiAlias; |
169 float m_minSizeForSubpixel; | 201 float m_minSizeForSubpixel; |
170 #endif | 202 #endif |
171 }; | 203 }; |
172 | 204 |
173 } // namespace blink | 205 } // namespace blink |
174 | 206 |
175 #endif // ifdef FontPlatformData_h | 207 #endif // ifdef FontPlatformData_h |
OLD | NEW |