]>
Commit | Line | Data |
---|---|---|
a90939db JF |
1 | /* |
2 | * This file is part of the internal font implementation. | |
3 | * | |
4 | * Copyright (C) 2006, 2008 Apple Inc. All rights reserved. | |
5 | * | |
6 | * This library is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU Library General Public | |
8 | * License as published by the Free Software Foundation; either | |
9 | * version 2 of the License, or (at your option) any later version. | |
10 | * | |
11 | * This library is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | * Library General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU Library General Public License | |
17 | * along with this library; see the file COPYING.LIB. If not, write to | |
18 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
19 | * Boston, MA 02110-1301, USA. | |
20 | * | |
21 | */ | |
22 | ||
23 | #ifndef SimpleFontData_h | |
24 | #define SimpleFontData_h | |
25 | ||
26 | #include "FontData.h" | |
27 | #include "FontPlatformData.h" | |
28 | #include "GlyphPageTreeNode.h" | |
29 | #include "GlyphWidthMap.h" | |
30 | #include <wtf/OwnPtr.h> | |
31 | ||
32 | #if USE(ATSUI) | |
33 | typedef struct OpaqueATSUStyle* ATSUStyle; | |
34 | #endif | |
35 | ||
36 | #if PLATFORM(WIN) | |
37 | #include <usp10.h> | |
38 | #endif | |
39 | ||
40 | #if PLATFORM(CAIRO) | |
41 | #include <cairo.h> | |
42 | #endif | |
43 | ||
44 | #if PLATFORM(QT) | |
45 | #include <QFont> | |
46 | #endif | |
47 | ||
48 | namespace WebCore { | |
49 | ||
50 | class FontDescription; | |
51 | class FontPlatformData; | |
52 | class SharedBuffer; | |
53 | class SVGFontData; | |
54 | class WidthMap; | |
55 | ||
56 | enum Pitch { UnknownPitch, FixedPitch, VariablePitch }; | |
57 | ||
58 | class SimpleFontData : public FontData { | |
59 | public: | |
60 | SimpleFontData(const FontPlatformData&, bool customFont = false, bool loading = false, SVGFontData* data = 0); | |
61 | virtual ~SimpleFontData(); | |
62 | ||
63 | public: | |
64 | const FontPlatformData& platformData() const { return m_font; } | |
65 | SimpleFontData* smallCapsFontData(const FontDescription& fontDescription) const; | |
66 | ||
67 | // vertical metrics | |
68 | int ascent() const { return m_ascent; } | |
69 | int descent() const { return m_descent; } | |
70 | int lineSpacing() const { return m_lineSpacing; } | |
71 | int lineGap() const { return m_lineGap; } | |
72 | float xHeight() const { return m_xHeight; } | |
73 | unsigned unitsPerEm() const { return m_unitsPerEm; } | |
74 | ||
75 | float widthForGlyph(Glyph) const; | |
76 | float platformWidthForGlyph(Glyph) const; | |
77 | ||
78 | virtual const SimpleFontData* fontDataForCharacter(UChar32) const; | |
79 | virtual bool containsCharacters(const UChar*, int length) const; | |
80 | ||
81 | void determinePitch(); | |
82 | Pitch pitch() const { return m_treatAsFixedPitch ? FixedPitch : VariablePitch; } | |
83 | ||
84 | #if ENABLE(SVG_FONTS) | |
85 | SVGFontData* svgFontData() const { return m_svgFontData.get(); } | |
86 | bool isSVGFont() const { return m_svgFontData; } | |
87 | #else | |
88 | bool isSVGFont() const { return false; } | |
89 | #endif | |
90 | ||
91 | virtual bool isCustomFont() const { return m_isCustomFont; } | |
92 | virtual bool isLoading() const { return m_isLoading; } | |
93 | virtual bool isSegmented() const; | |
94 | ||
95 | const GlyphData& missingGlyphData() const { return m_missingGlyphData; } | |
96 | ||
97 | GSFontRef getGSFont() const { return m_font.font(); } | |
98 | bool isImageFont() const { return m_font.m_isImageFont; }; | |
99 | ||
100 | #if USE(CORE_TEXT) | |
101 | CTFontRef getCTFont() const; | |
102 | CFDictionaryRef getCFStringAttributes() const; | |
103 | #endif | |
104 | ||
105 | #if USE(ATSUI) | |
106 | void checkShapesArabic() const; | |
107 | bool shapesArabic() const | |
108 | { | |
109 | if (!m_checkedShapesArabic) | |
110 | checkShapesArabic(); | |
111 | return m_shapesArabic; | |
112 | } | |
113 | #endif | |
114 | ||
115 | #if PLATFORM(QT) | |
116 | QFont getQtFont() const { return m_font.font(); } | |
117 | #endif | |
118 | ||
119 | #if PLATFORM(WIN) | |
120 | bool isSystemFont() const { return m_isSystemFont; } | |
121 | SCRIPT_FONTPROPERTIES* scriptFontProperties() const; | |
122 | SCRIPT_CACHE* scriptCache() const { return &m_scriptCache; } | |
123 | ||
124 | static void setShouldApplyMacAscentHack(bool); | |
125 | static bool shouldApplyMacAscentHack(); | |
126 | #endif | |
127 | ||
128 | #if PLATFORM(CAIRO) | |
129 | void setFont(cairo_t*) const; | |
130 | #endif | |
131 | ||
132 | #if PLATFORM(WX) | |
133 | wxFont getWxFont() const { return m_font.font(); } | |
134 | #endif | |
135 | ||
136 | private: | |
137 | void platformInit(); | |
138 | void platformGlyphInit(); | |
139 | void platformDestroy(); | |
140 | ||
141 | void commonInit(); | |
142 | ||
143 | #if PLATFORM(WIN) | |
144 | void initGDIFont(); | |
145 | void platformCommonDestroy(); | |
146 | float widthForGDIGlyph(Glyph glyph) const; | |
147 | #endif | |
148 | ||
149 | public: | |
150 | int m_ascent; | |
151 | int m_descent; | |
152 | int m_lineSpacing; | |
153 | int m_lineGap; | |
154 | float m_xHeight; | |
155 | unsigned m_unitsPerEm; | |
156 | ||
157 | FontPlatformData m_font; | |
158 | ||
159 | mutable GlyphWidthMap m_glyphToWidthMap; | |
160 | ||
161 | bool m_treatAsFixedPitch; | |
162 | ||
163 | #if ENABLE(SVG_FONTS) | |
164 | OwnPtr<SVGFontData> m_svgFontData; | |
165 | #endif | |
166 | ||
167 | bool m_isCustomFont; // Whether or not we are custom font loaded via @font-face | |
168 | bool m_isLoading; // Whether or not this custom font is still in the act of loading. | |
169 | ||
170 | Glyph m_spaceGlyph; | |
171 | float m_spaceWidth; | |
172 | float m_adjustedSpaceWidth; | |
173 | ||
174 | GlyphData m_missingGlyphData; | |
175 | ||
176 | mutable SimpleFontData* m_smallCapsFontData; | |
177 | ||
178 | #if PLATFORM(CG) || PLATFORM(WIN) | |
179 | float m_syntheticBoldOffset; | |
180 | #endif | |
181 | ||
182 | ||
183 | #if USE(ATSUI) | |
184 | mutable ATSUStyle m_ATSUStyle; | |
185 | mutable bool m_ATSUStyleInitialized; | |
186 | mutable bool m_ATSUMirrors; | |
187 | mutable bool m_checkedShapesArabic; | |
188 | mutable bool m_shapesArabic; | |
189 | #endif | |
190 | ||
191 | #if USE(CORE_TEXT) | |
192 | mutable RetainPtr<CTFontRef> m_CTFont; | |
193 | mutable RetainPtr<CFDictionaryRef> m_CFStringAttributes; | |
194 | #endif | |
195 | ||
196 | #if PLATFORM(WIN) | |
197 | bool m_isSystemFont; | |
198 | mutable SCRIPT_CACHE m_scriptCache; | |
199 | mutable SCRIPT_FONTPROPERTIES* m_scriptFontProperties; | |
200 | #endif | |
201 | }; | |
202 | ||
203 | } // namespace WebCore | |
204 | ||
205 | #endif // SimpleFontData_h |