2 * This file is part of the internal font implementation.
4 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
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.
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.
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.
23 #ifndef SimpleFontData_h
24 #define SimpleFontData_h
27 #include "FontPlatformData.h"
28 #include "GlyphPageTreeNode.h"
29 #include "GlyphWidthMap.h"
30 #include <wtf/OwnPtr.h>
33 typedef struct OpaqueATSUStyle
* ATSUStyle
;
50 class FontDescription
;
51 class FontPlatformData
;
56 enum Pitch
{ UnknownPitch
, FixedPitch
, VariablePitch
};
58 class SimpleFontData
: public FontData
{
60 SimpleFontData(const FontPlatformData
&, bool customFont
= false, bool loading
= false, SVGFontData
* data
= 0);
61 virtual ~SimpleFontData();
64 const FontPlatformData
& platformData() const { return m_font
; }
65 SimpleFontData
* smallCapsFontData(const FontDescription
& fontDescription
) const;
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
; }
75 float widthForGlyph(Glyph
) const;
76 float platformWidthForGlyph(Glyph
) const;
78 virtual const SimpleFontData
* fontDataForCharacter(UChar32
) const;
79 virtual bool containsCharacters(const UChar
*, int length
) const;
81 void determinePitch();
82 Pitch
pitch() const { return m_treatAsFixedPitch
? FixedPitch
: VariablePitch
; }
85 SVGFontData
* svgFontData() const { return m_svgFontData
.get(); }
86 bool isSVGFont() const { return m_svgFontData
; }
88 bool isSVGFont() const { return false; }
91 virtual bool isCustomFont() const { return m_isCustomFont
; }
92 virtual bool isLoading() const { return m_isLoading
; }
93 virtual bool isSegmented() const;
95 const GlyphData
& missingGlyphData() const { return m_missingGlyphData
; }
97 GSFontRef
getGSFont() const { return m_font
.font(); }
98 bool isImageFont() const { return m_font
.m_isImageFont
; };
101 CTFontRef
getCTFont() const;
102 CFDictionaryRef
getCFStringAttributes() const;
106 void checkShapesArabic() const;
107 bool shapesArabic() const
109 if (!m_checkedShapesArabic
)
111 return m_shapesArabic
;
116 QFont
getQtFont() const { return m_font
.font(); }
120 bool isSystemFont() const { return m_isSystemFont
; }
121 SCRIPT_FONTPROPERTIES
* scriptFontProperties() const;
122 SCRIPT_CACHE
* scriptCache() const { return &m_scriptCache
; }
124 static void setShouldApplyMacAscentHack(bool);
125 static bool shouldApplyMacAscentHack();
129 void setFont(cairo_t
*) const;
133 wxFont
getWxFont() const { return m_font
.font(); }
138 void platformGlyphInit();
139 void platformDestroy();
145 void platformCommonDestroy();
146 float widthForGDIGlyph(Glyph glyph
) const;
155 unsigned m_unitsPerEm
;
157 FontPlatformData m_font
;
159 mutable GlyphWidthMap m_glyphToWidthMap
;
161 bool m_treatAsFixedPitch
;
163 #if ENABLE(SVG_FONTS)
164 OwnPtr
<SVGFontData
> m_svgFontData
;
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.
172 float m_adjustedSpaceWidth
;
174 GlyphData m_missingGlyphData
;
176 mutable SimpleFontData
* m_smallCapsFontData
;
178 #if PLATFORM(CG) || PLATFORM(WIN)
179 float m_syntheticBoldOffset
;
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
;
192 mutable RetainPtr
<CTFontRef
> m_CTFont
;
193 mutable RetainPtr
<CFDictionaryRef
> m_CFStringAttributes
;
198 mutable SCRIPT_CACHE m_scriptCache
;
199 mutable SCRIPT_FONTPROPERTIES
* m_scriptFontProperties
;
203 } // namespace WebCore
205 #endif // SimpleFontData_h