OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef XFA_FGAS_FONT_FGAS_FONT_H_ | 7 #ifndef XFA_FGAS_FONT_FGAS_FONT_H_ |
8 #define XFA_FGAS_FONT_FGAS_FONT_H_ | 8 #define XFA_FGAS_FONT_FGAS_FONT_H_ |
9 | 9 |
10 #include "core/fxge/include/fx_font.h" | 10 #include "core/fxge/include/fx_font.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 virtual FX_BOOL GetBBox(CFX_Rect& bbox) = 0; | 94 virtual FX_BOOL GetBBox(CFX_Rect& bbox) = 0; |
95 virtual int32_t GetItalicAngle() const = 0; | 95 virtual int32_t GetItalicAngle() const = 0; |
96 virtual void Reset() = 0; | 96 virtual void Reset() = 0; |
97 virtual IFX_Font* GetSubstFont(int32_t iGlyphIndex) const = 0; | 97 virtual IFX_Font* GetSubstFont(int32_t iGlyphIndex) const = 0; |
98 virtual void* GetDevFont() const = 0; | 98 virtual void* GetDevFont() const = 0; |
99 virtual void SetFontProvider(IFX_FontProvider* pProvider) = 0; | 99 virtual void SetFontProvider(IFX_FontProvider* pProvider) = 0; |
100 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 100 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
101 virtual void SetLogicalFontStyle(uint32_t dwLogFontStyle) = 0; | 101 virtual void SetLogicalFontStyle(uint32_t dwLogFontStyle) = 0; |
102 #endif | 102 #endif |
103 }; | 103 }; |
| 104 |
104 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 105 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
105 struct FX_FONTMATCHPARAMS { | 106 struct FX_FONTMATCHPARAMS { |
106 const FX_WCHAR* pwsFamily; | 107 const FX_WCHAR* pwsFamily; |
107 uint32_t dwFontStyles; | 108 uint32_t dwFontStyles; |
108 uint32_t dwUSB; | 109 uint32_t dwUSB; |
109 uint32_t dwMatchFlags; | 110 uint32_t dwMatchFlags; |
110 FX_WCHAR wUnicode; | 111 FX_WCHAR wUnicode; |
111 uint16_t wCodePage; | 112 uint16_t wCodePage; |
112 }; | 113 }; |
113 typedef FX_FONTMATCHPARAMS* FX_LPFONTMATCHPARAMS; | 114 typedef FX_FONTMATCHPARAMS* FX_LPFONTMATCHPARAMS; |
114 typedef FX_FONTMATCHPARAMS const* FX_LPCFONTMATCHPARAMS; | 115 typedef FX_FONTMATCHPARAMS const* FX_LPCFONTMATCHPARAMS; |
115 | 116 |
116 struct FX_FONTSIGNATURE { | 117 struct FX_FONTSIGNATURE { |
117 uint32_t fsUsb[4]; | 118 uint32_t fsUsb[4]; |
118 uint32_t fsCsb[2]; | 119 uint32_t fsCsb[2]; |
119 }; | 120 }; |
120 inline bool operator==(const FX_FONTSIGNATURE& left, | 121 inline bool operator==(const FX_FONTSIGNATURE& left, |
121 const FX_FONTSIGNATURE& right) { | 122 const FX_FONTSIGNATURE& right) { |
122 return left.fsUsb[0] == right.fsUsb[0] && left.fsUsb[1] == right.fsUsb[1] && | 123 return left.fsUsb[0] == right.fsUsb[0] && left.fsUsb[1] == right.fsUsb[1] && |
123 left.fsUsb[2] == right.fsUsb[2] && left.fsUsb[3] == right.fsUsb[3] && | 124 left.fsUsb[2] == right.fsUsb[2] && left.fsUsb[3] == right.fsUsb[3] && |
124 left.fsCsb[0] == right.fsCsb[0] && left.fsCsb[1] == right.fsCsb[1]; | 125 left.fsCsb[0] == right.fsCsb[0] && left.fsCsb[1] == right.fsCsb[1]; |
125 } | 126 } |
126 | 127 |
127 struct FX_FONTDESCRIPTOR { | 128 struct FX_FONTDESCRIPTOR { |
128 FX_WCHAR wsFontFace[32]; | 129 FX_WCHAR wsFontFace[32]; |
129 uint32_t dwFontStyles; | 130 uint32_t dwFontStyles; |
130 uint8_t uCharSet; | 131 uint8_t uCharSet; |
131 FX_FONTSIGNATURE FontSignature; | 132 FX_FONTSIGNATURE FontSignature; |
132 }; | 133 }; |
133 typedef FX_FONTDESCRIPTOR* FX_LPFONTDESCRIPTOR; | 134 |
134 typedef FX_FONTDESCRIPTOR const* FX_LPCFONTDESCRIPTOR; | |
135 typedef CFX_MassArrayTemplate<FX_FONTDESCRIPTOR> CFX_FontDescriptors; | 135 typedef CFX_MassArrayTemplate<FX_FONTDESCRIPTOR> CFX_FontDescriptors; |
136 inline bool operator==(const FX_FONTDESCRIPTOR& left, | 136 inline bool operator==(const FX_FONTDESCRIPTOR& left, |
137 const FX_FONTDESCRIPTOR& right) { | 137 const FX_FONTDESCRIPTOR& right) { |
138 return left.uCharSet == right.uCharSet && | 138 return left.uCharSet == right.uCharSet && |
139 left.dwFontStyles == right.dwFontStyles && | 139 left.dwFontStyles == right.dwFontStyles && |
140 left.FontSignature == right.FontSignature && | 140 left.FontSignature == right.FontSignature && |
141 FXSYS_wcscmp(left.wsFontFace, right.wsFontFace) == 0; | 141 FXSYS_wcscmp(left.wsFontFace, right.wsFontFace) == 0; |
142 } | 142 } |
143 | 143 |
144 #define FX_FONTMATCHPARA_MacthStyle 0x01 | 144 #define FX_FONTMATCHPARA_MacthStyle 0x01 |
145 #define FX_FONTMATCHPARA_MacthFamily 0x02 | 145 #define FX_FONTMATCHPARA_MacthFamily 0x02 |
146 #define FX_FONTMATCHPARA_MacthUnicode 0x04 | 146 #define FX_FONTMATCHPARA_MacthUnicode 0x04 |
147 typedef void (*FX_LPEnumAllFonts)(CFX_FontDescriptors& fonts, | 147 typedef void (*FX_LPEnumAllFonts)(CFX_FontDescriptors& fonts, |
148 void* pUserData, | |
149 const FX_WCHAR* pwsFaceName, | 148 const FX_WCHAR* pwsFaceName, |
150 FX_WCHAR wUnicode); | 149 FX_WCHAR wUnicode); |
151 FX_LPEnumAllFonts FX_GetDefFontEnumerator(); | 150 FX_LPEnumAllFonts FX_GetDefFontEnumerator(); |
152 typedef FX_LPCFONTDESCRIPTOR (*FX_LPMatchFont)(FX_LPFONTMATCHPARAMS pParams, | 151 typedef FX_FONTDESCRIPTOR const* (*FX_LPMatchFont)( |
153 const CFX_FontDescriptors& fonts, | 152 FX_LPFONTMATCHPARAMS pParams, |
154 void* pUserData); | 153 const CFX_FontDescriptors& fonts); |
155 FX_LPMatchFont FX_GetDefFontMatchor(); | 154 FX_LPMatchFont FX_GetDefFontMatchor(); |
156 class IFX_FontMgr { | 155 class IFX_FontMgr { |
157 public: | 156 public: |
158 static IFX_FontMgr* Create(FX_LPEnumAllFonts pEnumerator, | 157 static IFX_FontMgr* Create(FX_LPEnumAllFonts pEnumerator); |
159 FX_LPMatchFont pMatcher = NULL, | |
160 void* pUserData = NULL); | |
161 virtual ~IFX_FontMgr() {} | 158 virtual ~IFX_FontMgr() {} |
162 virtual void Release() = 0; | 159 virtual void Release() = 0; |
163 virtual IFX_Font* GetDefFontByCodePage( | 160 virtual IFX_Font* GetDefFontByCodePage( |
164 uint16_t wCodePage, | 161 uint16_t wCodePage, |
165 uint32_t dwFontStyles, | 162 uint32_t dwFontStyles, |
166 const FX_WCHAR* pszFontFamily = NULL) = 0; | 163 const FX_WCHAR* pszFontFamily = NULL) = 0; |
167 virtual IFX_Font* GetDefFontByCharset( | 164 virtual IFX_Font* GetDefFontByCharset( |
168 uint8_t nCharset, | 165 uint8_t nCharset, |
169 uint32_t dwFontStyles, | 166 uint32_t dwFontStyles, |
170 const FX_WCHAR* pszFontFamily = NULL) = 0; | 167 const FX_WCHAR* pszFontFamily = NULL) = 0; |
(...skipping 14 matching lines...) Expand all Loading... |
185 const FX_WCHAR* pszFontAlias = NULL, | 182 const FX_WCHAR* pszFontAlias = NULL, |
186 uint32_t dwFontStyles = 0, | 183 uint32_t dwFontStyles = 0, |
187 uint16_t wCodePage = 0, | 184 uint16_t wCodePage = 0, |
188 FX_BOOL bSaveStream = FALSE) = 0; | 185 FX_BOOL bSaveStream = FALSE) = 0; |
189 virtual IFX_Font* LoadFont(IFX_Font* pSrcFont, | 186 virtual IFX_Font* LoadFont(IFX_Font* pSrcFont, |
190 uint32_t dwFontStyles, | 187 uint32_t dwFontStyles, |
191 uint16_t wCodePage = 0xFFFF) = 0; | 188 uint16_t wCodePage = 0xFFFF) = 0; |
192 virtual void ClearFontCache() = 0; | 189 virtual void ClearFontCache() = 0; |
193 virtual void RemoveFont(IFX_Font* pFont) = 0; | 190 virtual void RemoveFont(IFX_Font* pFont) = 0; |
194 }; | 191 }; |
195 #else | 192 |
196 class IFX_FontMgrDelegate { | 193 #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
197 public: | 194 |
198 virtual ~IFX_FontMgrDelegate() {} | |
199 virtual IFX_Font* GetDefFontByCodePage( | |
200 IFX_FontMgr* pFontMgr, | |
201 uint16_t wCodePage, | |
202 uint32_t dwFontStyles, | |
203 const FX_WCHAR* pszFontFamily = NULL) = 0; | |
204 virtual IFX_Font* GetDefFontByCharset( | |
205 IFX_FontMgr* pFontMgr, | |
206 uint8_t nCharset, | |
207 uint32_t dwFontStyles, | |
208 const FX_WCHAR* pszFontFamily = NULL) = 0; | |
209 virtual IFX_Font* GetDefFontByUnicode( | |
210 IFX_FontMgr* pFontMgr, | |
211 FX_WCHAR wUnicode, | |
212 uint32_t dwFontStyles, | |
213 const FX_WCHAR* pszFontFamily = NULL) = 0; | |
214 virtual IFX_Font* GetDefFontByLanguage( | |
215 IFX_FontMgr* pFontMgr, | |
216 uint16_t wLanguage, | |
217 uint32_t dwFontStyles, | |
218 const FX_WCHAR* pszFontFamily = NULL) = 0; | |
219 }; | |
220 class IFX_FontSourceEnum { | 195 class IFX_FontSourceEnum { |
221 public: | 196 public: |
222 virtual ~IFX_FontSourceEnum() {} | 197 virtual ~IFX_FontSourceEnum() {} |
223 virtual void Release() = 0; | 198 virtual void Release() = 0; |
224 virtual FX_POSITION GetStartPosition(void* pUserData = NULL) = 0; | 199 virtual FX_POSITION GetStartPosition() = 0; |
225 virtual IFX_FileAccess* GetNext(FX_POSITION& pos, void* pUserData = NULL) = 0; | 200 virtual IFX_FileAccess* GetNext(FX_POSITION& pos) = 0; |
226 }; | 201 }; |
227 IFX_FontSourceEnum* FX_CreateDefaultFontSourceEnum(); | 202 IFX_FontSourceEnum* FX_CreateDefaultFontSourceEnum(); |
228 class IFX_FontMgr { | 203 class IFX_FontMgr { |
229 public: | 204 public: |
230 static IFX_FontMgr* Create(IFX_FontSourceEnum* pFontEnum, | 205 static IFX_FontMgr* Create(IFX_FontSourceEnum* pFontEnum); |
231 IFX_FontMgrDelegate* pDelegate = NULL, | |
232 void* pUserData = NULL); | |
233 virtual ~IFX_FontMgr() {} | 206 virtual ~IFX_FontMgr() {} |
234 virtual void Release() = 0; | 207 virtual void Release() = 0; |
235 virtual IFX_Font* GetDefFontByCodePage( | 208 virtual IFX_Font* GetDefFontByCodePage( |
236 uint16_t wCodePage, | 209 uint16_t wCodePage, |
237 uint32_t dwFontStyles, | 210 uint32_t dwFontStyles, |
238 const FX_WCHAR* pszFontFamily = NULL) = 0; | 211 const FX_WCHAR* pszFontFamily = NULL) = 0; |
239 virtual IFX_Font* GetDefFontByCharset( | 212 virtual IFX_Font* GetDefFontByCharset( |
240 uint8_t nCharset, | 213 uint8_t nCharset, |
241 uint32_t dwFontStyles, | 214 uint32_t dwFontStyles, |
242 const FX_WCHAR* pszFontFamily = NULL) = 0; | 215 const FX_WCHAR* pszFontFamily = NULL) = 0; |
(...skipping 30 matching lines...) Expand all Loading... |
273 int32_t iFaceIndex, | 246 int32_t iFaceIndex, |
274 int32_t* pFaceCount = NULL) = 0; | 247 int32_t* pFaceCount = NULL) = 0; |
275 virtual IFX_Font* LoadFont(IFX_Stream* pFontStream, | 248 virtual IFX_Font* LoadFont(IFX_Stream* pFontStream, |
276 int32_t iFaceIndex, | 249 int32_t iFaceIndex, |
277 int32_t* pFaceCount = NULL, | 250 int32_t* pFaceCount = NULL, |
278 FX_BOOL bSaveStream = FALSE) = 0; | 251 FX_BOOL bSaveStream = FALSE) = 0; |
279 | 252 |
280 virtual void ClearFontCache() = 0; | 253 virtual void ClearFontCache() = 0; |
281 virtual void RemoveFont(IFX_Font* pFont) = 0; | 254 virtual void RemoveFont(IFX_Font* pFont) = 0; |
282 }; | 255 }; |
283 #endif | 256 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
284 | 257 |
285 #endif // XFA_FGAS_FONT_FGAS_FONT_H_ | 258 #endif // XFA_FGAS_FONT_FGAS_FONT_H_ |
OLD | NEW |