00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef BTFontData_h
00024 #define BTFontData_h
00025
00026 #include "FontPlatformData.h"
00027 #include "GlyphPageTreeNode.h"
00028 #include "GlyphWidthMap.h"
00029 #include <wtf/Noncopyable.h>
00030
00031 #include <wtf/unicode/Unicode.h>
00032
00033 #if PLATFORM(MAC)
00034 typedef struct OpaqueATSUStyle* ATSUStyle;
00035 #endif
00036
00037 #if PLATFORM(WIN)
00038 #include <usp10.h>
00039 #endif
00040
00041 namespace WebCore {
00042
00043 class FontDescription;
00044 class FontPlatformData;
00045 class SharedBuffer;
00046 class WidthMap;
00047
00048 #ifdef __OWB__
00049 }
00050
00051 using WebCore::GlyphWidthMap;
00052
00053 namespace BAL {
00054 #endif //__OWB__
00055
00056 enum Pitch { UnknownPitch, FixedPitch, VariablePitch };
00057
00058 class BTFontData : Noncopyable {
00059 public:
00060 BTFontData(const FontPlatformData&, bool customFont = false, bool loading = false);
00061 ~BTFontData();
00062
00063 public:
00064
00065 const FontPlatformData& platformData() const { return m_font; }
00066
00067 BTFontData* smallCapsFontData(const FontDescription& fontDescription) const;
00068
00069
00070 int ascent() const { return m_ascent; }
00071 int descent() const { return m_descent; }
00072 int lineSpacing() const { return m_lineSpacing; }
00073 int lineGap() const { return m_lineGap; }
00074 float xHeight() const { return m_xHeight; }
00075 unsigned unitsPerEm() const { return m_unitsPerEm; }
00076
00077 float widthForGlyph(Glyph) const;
00078 float platformWidthForGlyph(Glyph) const;
00079
00080 bool containsCharacters(const UChar* characters, int length) const;
00081
00082 void determinePitch();
00083 Pitch pitch() const { return m_treatAsFixedPitch ? FixedPitch : VariablePitch; }
00084
00085 bool isCustomFont() const { return m_isCustomFont; }
00086 bool isLoading() const { return m_isLoading; }
00087
00088 const GlyphData& missingGlyphData() const { return m_missingGlyphData; }
00089
00090 #if PLATFORM(MAC)
00091 NSFont* getNSFont() const { return m_font.font(); }
00092 void checkShapesArabic() const;
00093 bool shapesArabic() const
00094 {
00095 if (!m_checkedShapesArabic)
00096 checkShapesArabic();
00097 return m_shapesArabic;
00098 }
00099 #endif
00100
00101 #if PLATFORM(WIN)
00102 bool isSystemFont() const { return m_isSystemFont; }
00103 SCRIPT_FONTPROPERTIES* scriptFontProperties() const;
00104 SCRIPT_CACHE* scriptCache() const { return &m_scriptCache; }
00105 #endif
00106
00107 #if PLATFORM(GTK)
00108 void setFont(cairo_t*) const;
00109 #endif
00110
00111 private:
00112 void platformInit();
00113 void platformDestroy();
00114
00115 void commonInit();
00116
00117 public:
00118 int m_ascent;
00119 int m_descent;
00120 int m_lineSpacing;
00121 int m_lineGap;
00122 float m_xHeight;
00123 unsigned m_unitsPerEm;
00124
00125 FontPlatformData m_font;
00126
00127 mutable GlyphWidthMap m_glyphToWidthMap;
00128
00129 bool m_treatAsFixedPitch;
00130
00131 bool m_isCustomFont;
00132 bool m_isLoading;
00133
00134 Glyph m_spaceGlyph;
00135 float m_spaceWidth;
00136 float m_adjustedSpaceWidth;
00137
00138 GlyphData m_missingGlyphData;
00139
00140 mutable BTFontData* m_smallCapsFontData;
00141
00142 #if PLATFORM(CG)
00143 float m_syntheticBoldOffset;
00144 #endif
00145
00146 #if PLATFORM(MAC)
00147 void* m_styleGroup;
00148 mutable ATSUStyle m_ATSUStyle;
00149 mutable bool m_ATSUStyleInitialized;
00150 mutable bool m_ATSUMirrors;
00151 mutable bool m_checkedShapesArabic;
00152 mutable bool m_shapesArabic;
00153 #endif
00154
00155 #if PLATFORM(WIN)
00156 bool m_isSystemFont;
00157 mutable SCRIPT_CACHE m_scriptCache;
00158 mutable SCRIPT_FONTPROPERTIES* m_scriptFontProperties;
00159 #endif
00160 };
00161
00162 }
00163
00164 #endif // BTFontData_h