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_STDFONTMGR_H_ | 7 #ifndef XFA_FGAS_FONT_FGAS_STDFONTMGR_H_ |
8 #define XFA_FGAS_FONT_FGAS_STDFONTMGR_H_ | 8 #define XFA_FGAS_FONT_FGAS_STDFONTMGR_H_ |
9 | 9 |
10 #include "core/fxcrt/include/fx_ext.h" | 10 #include "core/fxcrt/include/fx_ext.h" |
11 #include "core/fxge/include/fx_freetype.h" | 11 #include "core/fxge/include/fx_freetype.h" |
12 #include "third_party/freetype/include/freetype/fttypes.h" | 12 #include "third_party/freetype/include/freetype/fttypes.h" |
13 #include "xfa/fgas/font/fgas_font.h" | 13 #include "xfa/fgas/font/fgas_font.h" |
14 | 14 |
15 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 15 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
16 int32_t FX_GetSimilarValue(FX_FONTDESCRIPTOR const* pFont, | 16 int32_t FX_GetSimilarValue(FX_FONTDESCRIPTOR const* pFont, |
17 uint32_t dwFontStyles); | 17 uint32_t dwFontStyles); |
18 FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, | 18 FX_FONTDESCRIPTOR const* FX_DefFontMatcher(FX_LPFONTMATCHPARAMS pParams, |
19 const CFX_FontDescriptors& fonts); | 19 const CFX_FontDescriptors& fonts); |
20 | 20 |
21 class CFGAS_StdFontMgrImp : public IFGAS_FontMgr { | 21 class CFGAS_StdFontMgrImp : public IFGAS_FontMgr { |
22 public: | 22 public: |
23 explicit CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator); | 23 explicit CFGAS_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator); |
24 ~CFGAS_StdFontMgrImp() override; | 24 ~CFGAS_StdFontMgrImp() override; |
25 | 25 |
26 // IFGAS_FontMgr: | 26 // IFGAS_FontMgr: |
27 void Release() override { delete this; } | 27 void Release() override { delete this; } |
28 IFGAS_Font* GetDefFontByCodePage( | 28 CFGAS_GEFont* GetDefFontByCodePage( |
29 uint16_t wCodePage, | 29 uint16_t wCodePage, |
30 uint32_t dwFontStyles, | 30 uint32_t dwFontStyles, |
31 const FX_WCHAR* pszFontFamily = NULL) override; | 31 const FX_WCHAR* pszFontFamily = NULL) override; |
32 IFGAS_Font* GetDefFontByCharset( | 32 CFGAS_GEFont* GetDefFontByCharset( |
33 uint8_t nCharset, | 33 uint8_t nCharset, |
34 uint32_t dwFontStyles, | 34 uint32_t dwFontStyles, |
35 const FX_WCHAR* pszFontFamily = NULL) override; | 35 const FX_WCHAR* pszFontFamily = NULL) override; |
36 IFGAS_Font* GetDefFontByUnicode( | 36 CFGAS_GEFont* GetDefFontByUnicode( |
37 FX_WCHAR wUnicode, | 37 FX_WCHAR wUnicode, |
38 uint32_t dwFontStyles, | 38 uint32_t dwFontStyles, |
39 const FX_WCHAR* pszFontFamily = NULL) override; | 39 const FX_WCHAR* pszFontFamily = NULL) override; |
40 IFGAS_Font* GetDefFontByLanguage( | 40 CFGAS_GEFont* GetDefFontByLanguage( |
41 uint16_t wLanguage, | 41 uint16_t wLanguage, |
42 uint32_t dwFontStyles, | 42 uint32_t dwFontStyles, |
43 const FX_WCHAR* pszFontFamily = NULL) override; | 43 const FX_WCHAR* pszFontFamily = NULL) override; |
44 IFGAS_Font* LoadFont(const FX_WCHAR* pszFontFamily, | 44 CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, |
45 uint32_t dwFontStyles, | 45 uint32_t dwFontStyles, |
46 uint16_t wCodePage = 0xFFFF) override; | 46 uint16_t wCodePage = 0xFFFF) override; |
47 IFGAS_Font* LoadFont(const uint8_t* pBuffer, int32_t iLength) override; | 47 CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, int32_t iLength) override; |
48 IFGAS_Font* LoadFont(const FX_WCHAR* pszFileName) override; | 48 CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFileName) override; |
49 IFGAS_Font* LoadFont(IFX_Stream* pFontStream, | 49 CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, |
50 const FX_WCHAR* pszFontAlias = NULL, | 50 const FX_WCHAR* pszFontAlias = NULL, |
51 uint32_t dwFontStyles = 0, | 51 uint32_t dwFontStyles = 0, |
52 uint16_t wCodePage = 0, | 52 uint16_t wCodePage = 0, |
53 FX_BOOL bSaveStream = FALSE) override; | 53 FX_BOOL bSaveStream = FALSE) override; |
54 IFGAS_Font* LoadFont(IFGAS_Font* pSrcFont, | 54 CFGAS_GEFont* LoadFont(CFGAS_GEFont* pSrcFont, |
55 uint32_t dwFontStyles, | 55 uint32_t dwFontStyles, |
56 uint16_t wCodePage = 0xFFFF) override; | 56 uint16_t wCodePage = 0xFFFF) override; |
57 | 57 |
58 void ClearFontCache() override; | 58 void ClearFontCache() override; |
59 void RemoveFont(IFGAS_Font* pFont) override; | 59 void RemoveFont(CFGAS_GEFont* pFont) override; |
60 | 60 |
61 protected: | 61 protected: |
62 void RemoveFont(CFX_MapPtrToPtr& fontMap, IFGAS_Font* pFont); | 62 void RemoveFont(CFX_MapPtrToPtr& fontMap, CFGAS_GEFont* pFont); |
63 FX_FONTDESCRIPTOR const* FindFont(const FX_WCHAR* pszFontFamily, | 63 FX_FONTDESCRIPTOR const* FindFont(const FX_WCHAR* pszFontFamily, |
64 uint32_t dwFontStyles, | 64 uint32_t dwFontStyles, |
65 uint32_t dwMatchFlags, | 65 uint32_t dwMatchFlags, |
66 uint16_t wCodePage, | 66 uint16_t wCodePage, |
67 uint32_t dwUSB = 999, | 67 uint32_t dwUSB = 999, |
68 FX_WCHAR wUnicode = 0); | 68 FX_WCHAR wUnicode = 0); |
69 IFGAS_Font* GetFont(FX_FONTDESCRIPTOR const* pFD, uint32_t dwFontStyles); | 69 CFGAS_GEFont* GetFont(FX_FONTDESCRIPTOR const* pFD, uint32_t dwFontStyles); |
70 | 70 |
71 FX_LPEnumAllFonts m_pEnumerator; | 71 FX_LPEnumAllFonts m_pEnumerator; |
72 CFX_FontDescriptors m_FontFaces; | 72 CFX_FontDescriptors m_FontFaces; |
73 CFX_ArrayTemplate<IFGAS_Font*> m_Fonts; | 73 CFX_ArrayTemplate<CFGAS_GEFont*> m_Fonts; |
74 CFX_MapPtrToPtr m_CPFonts; | 74 CFX_MapPtrToPtr m_CPFonts; |
75 CFX_MapPtrToPtr m_FamilyFonts; | 75 CFX_MapPtrToPtr m_FamilyFonts; |
76 CFX_MapPtrToPtr m_UnicodeFonts; | 76 CFX_MapPtrToPtr m_UnicodeFonts; |
77 CFX_MapPtrToPtr m_BufferFonts; | 77 CFX_MapPtrToPtr m_BufferFonts; |
78 CFX_MapPtrToPtr m_FileFonts; | 78 CFX_MapPtrToPtr m_FileFonts; |
79 CFX_MapPtrToPtr m_StreamFonts; | 79 CFX_MapPtrToPtr m_StreamFonts; |
80 CFX_MapPtrToPtr m_DeriveFonts; | 80 CFX_MapPtrToPtr m_DeriveFonts; |
81 }; | 81 }; |
82 uint32_t FX_GetGdiFontStyles(const LOGFONTW& lf); | 82 uint32_t FX_GetGdiFontStyles(const LOGFONTW& lf); |
83 | 83 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 CFX_ByteStringArray m_FolderPaths; | 148 CFX_ByteStringArray m_FolderPaths; |
149 }; | 149 }; |
150 | 150 |
151 class CFGAS_FontMgrImp : public IFGAS_FontMgr { | 151 class CFGAS_FontMgrImp : public IFGAS_FontMgr { |
152 public: | 152 public: |
153 explicit CFGAS_FontMgrImp(CFX_FontSourceEnum_File* pFontEnum); | 153 explicit CFGAS_FontMgrImp(CFX_FontSourceEnum_File* pFontEnum); |
154 ~CFGAS_FontMgrImp() override; | 154 ~CFGAS_FontMgrImp() override; |
155 | 155 |
156 // IFGAS_FontMgr: | 156 // IFGAS_FontMgr: |
157 void Release() override; | 157 void Release() override; |
158 IFGAS_Font* GetDefFontByCodePage( | 158 CFGAS_GEFont* GetDefFontByCodePage( |
159 uint16_t wCodePage, | 159 uint16_t wCodePage, |
160 uint32_t dwFontStyles, | 160 uint32_t dwFontStyles, |
161 const FX_WCHAR* pszFontFamily = NULL) override; | 161 const FX_WCHAR* pszFontFamily = NULL) override; |
162 IFGAS_Font* GetDefFontByCharset( | 162 CFGAS_GEFont* GetDefFontByCharset( |
163 uint8_t nCharset, | 163 uint8_t nCharset, |
164 uint32_t dwFontStyles, | 164 uint32_t dwFontStyles, |
165 const FX_WCHAR* pszFontFamily = NULL) override; | 165 const FX_WCHAR* pszFontFamily = NULL) override; |
166 IFGAS_Font* GetDefFontByUnicode( | 166 CFGAS_GEFont* GetDefFontByUnicode( |
167 FX_WCHAR wUnicode, | 167 FX_WCHAR wUnicode, |
168 uint32_t dwFontStyles, | 168 uint32_t dwFontStyles, |
169 const FX_WCHAR* pszFontFamily = NULL) override; | 169 const FX_WCHAR* pszFontFamily = NULL) override; |
170 IFGAS_Font* GetDefFontByLanguage( | 170 CFGAS_GEFont* GetDefFontByLanguage( |
171 uint16_t wLanguage, | 171 uint16_t wLanguage, |
172 uint32_t dwFontStyles, | 172 uint32_t dwFontStyles, |
173 const FX_WCHAR* pszFontFamily = NULL) override; | 173 const FX_WCHAR* pszFontFamily = NULL) override; |
174 IFGAS_Font* GetFontByCodePage(uint16_t wCodePage, | 174 CFGAS_GEFont* GetFontByCodePage( |
175 uint32_t dwFontStyles, | 175 uint16_t wCodePage, |
176 const FX_WCHAR* pszFontFamily = NULL) override; | 176 uint32_t dwFontStyles, |
177 IFGAS_Font* GetFontByCharset(uint8_t nCharset, | 177 const FX_WCHAR* pszFontFamily = NULL) override; |
178 uint32_t dwFontStyles, | 178 CFGAS_GEFont* GetFontByCharset(uint8_t nCharset, |
179 const FX_WCHAR* pszFontFamily = NULL) override; | 179 uint32_t dwFontStyles, |
180 IFGAS_Font* GetFontByUnicode(FX_WCHAR wUnicode, | 180 const FX_WCHAR* pszFontFamily = NULL) override; |
181 uint32_t dwFontStyles, | 181 CFGAS_GEFont* GetFontByUnicode(FX_WCHAR wUnicode, |
182 const FX_WCHAR* pszFontFamily = NULL) override; | 182 uint32_t dwFontStyles, |
183 IFGAS_Font* GetFontByLanguage(uint16_t wLanguage, | 183 const FX_WCHAR* pszFontFamily = NULL) override; |
184 uint32_t dwFontStyles, | 184 CFGAS_GEFont* GetFontByLanguage( |
185 const FX_WCHAR* pszFontFamily = NULL) override; | 185 uint16_t wLanguage, |
186 IFGAS_Font* LoadFont(const uint8_t* pBuffer, | 186 uint32_t dwFontStyles, |
187 int32_t iLength, | 187 const FX_WCHAR* pszFontFamily = NULL) override; |
188 int32_t iFaceIndex, | 188 CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, |
189 int32_t* pFaceCount) override; | 189 int32_t iLength, |
190 IFGAS_Font* LoadFont(const FX_WCHAR* pszFileName, | 190 int32_t iFaceIndex, |
191 int32_t iFaceIndex, | 191 int32_t* pFaceCount) override; |
192 int32_t* pFaceCount) override; | 192 CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFileName, |
193 IFGAS_Font* LoadFont(IFX_Stream* pFontStream, | 193 int32_t iFaceIndex, |
194 int32_t iFaceIndex, | 194 int32_t* pFaceCount) override; |
195 int32_t* pFaceCount, | 195 CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, |
196 FX_BOOL bSaveStream = FALSE) override; | 196 int32_t iFaceIndex, |
| 197 int32_t* pFaceCount, |
| 198 FX_BOOL bSaveStream = FALSE) override; |
197 void ClearFontCache() override; | 199 void ClearFontCache() override; |
198 void RemoveFont(IFGAS_Font* pFont) override; | 200 void RemoveFont(CFGAS_GEFont* pFont) override; |
199 | 201 |
200 IFGAS_Font* LoadFont(const CFX_WideString& wsFaceName, | 202 CFGAS_GEFont* LoadFont(const CFX_WideString& wsFaceName, |
201 int32_t iFaceIndex, | 203 int32_t iFaceIndex, |
202 int32_t* pFaceCount); | 204 int32_t* pFaceCount); |
203 FX_BOOL EnumFonts(); | 205 FX_BOOL EnumFonts(); |
204 FX_BOOL EnumFontsFromFontMapper(); | 206 FX_BOOL EnumFontsFromFontMapper(); |
205 FX_BOOL EnumFontsFromFiles(); | 207 FX_BOOL EnumFontsFromFiles(); |
206 | 208 |
207 protected: | 209 protected: |
208 void RegisterFace(FXFT_Face pFace, | 210 void RegisterFace(FXFT_Face pFace, |
209 CFX_FontDescriptors& Fonts, | 211 CFX_FontDescriptors& Fonts, |
210 const CFX_WideString* pFaceName, | 212 const CFX_WideString* pFaceName, |
211 IFX_FileAccess* pFontAccess); | 213 IFX_FileAccess* pFontAccess); |
212 void RegisterFaces(IFX_FileRead* pFontStream, | 214 void RegisterFaces(IFX_FileRead* pFontStream, |
213 const CFX_WideString* pFaceName); | 215 const CFX_WideString* pFaceName); |
214 void GetNames(const uint8_t* name_table, CFX_WideStringArray& Names); | 216 void GetNames(const uint8_t* name_table, CFX_WideStringArray& Names); |
215 void GetCharsets(FXFT_Face pFace, CFX_ArrayTemplate<uint16_t>& Charsets); | 217 void GetCharsets(FXFT_Face pFace, CFX_ArrayTemplate<uint16_t>& Charsets); |
216 void GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB); | 218 void GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB); |
217 uint32_t GetFlags(FXFT_Face pFace); | 219 uint32_t GetFlags(FXFT_Face pFace); |
218 CFX_FontDescriptors m_InstalledFonts; | 220 CFX_FontDescriptors m_InstalledFonts; |
219 FX_BOOL VerifyUnicode(CFX_FontDescriptor* pDesc, FX_WCHAR wcUnicode); | 221 FX_BOOL VerifyUnicode(CFX_FontDescriptor* pDesc, FX_WCHAR wcUnicode); |
220 FX_BOOL VerifyUnicode(IFGAS_Font* pFont, FX_WCHAR wcUnicode); | 222 FX_BOOL VerifyUnicode(CFGAS_GEFont* pFont, FX_WCHAR wcUnicode); |
221 int32_t IsPartName(const CFX_WideString& Name1, const CFX_WideString& Name2); | 223 int32_t IsPartName(const CFX_WideString& Name1, const CFX_WideString& Name2); |
222 int32_t MatchFonts(CFX_FontDescriptorInfos& MatchedFonts, | 224 int32_t MatchFonts(CFX_FontDescriptorInfos& MatchedFonts, |
223 uint16_t wCodePage, | 225 uint16_t wCodePage, |
224 uint32_t dwFontStyles, | 226 uint32_t dwFontStyles, |
225 const CFX_WideString& FontName, | 227 const CFX_WideString& FontName, |
226 FX_WCHAR wcUnicode = 0xFFFE); | 228 FX_WCHAR wcUnicode = 0xFFFE); |
227 int32_t CalcPenalty(CFX_FontDescriptor* pInstalled, | 229 int32_t CalcPenalty(CFX_FontDescriptor* pInstalled, |
228 uint16_t wCodePage, | 230 uint16_t wCodePage, |
229 uint32_t dwFontStyles, | 231 uint32_t dwFontStyles, |
230 const CFX_WideString& FontName, | 232 const CFX_WideString& FontName, |
231 FX_WCHAR wcUnicode = 0xFFFE); | 233 FX_WCHAR wcUnicode = 0xFFFE); |
232 IFGAS_Font* LoadFont(IFX_FileAccess* pFontAccess, | 234 CFGAS_GEFont* LoadFont(IFX_FileAccess* pFontAccess, |
233 int32_t iFaceIndex, | 235 int32_t iFaceIndex, |
234 int32_t* pFaceCount, | 236 int32_t* pFaceCount, |
235 FX_BOOL bWantCache = FALSE); | 237 FX_BOOL bWantCache = FALSE); |
236 FXFT_Face LoadFace(IFX_FileRead* pFontStream, int32_t iFaceIndex); | 238 FXFT_Face LoadFace(IFX_FileRead* pFontStream, int32_t iFaceIndex); |
237 IFX_FileRead* CreateFontStream(CFX_FontMapper* pFontMapper, | 239 IFX_FileRead* CreateFontStream(CFX_FontMapper* pFontMapper, |
238 IFX_SystemFontInfo* pSystemFontInfo, | 240 IFX_SystemFontInfo* pSystemFontInfo, |
239 uint32_t index); | 241 uint32_t index); |
240 IFX_FileRead* CreateFontStream(const CFX_ByteString& bsFaceName); | 242 IFX_FileRead* CreateFontStream(const CFX_ByteString& bsFaceName); |
241 | 243 |
242 CFX_MapPtrTemplate<uint32_t, CFX_FontDescriptorInfos*> m_Hash2CandidateList; | 244 CFX_MapPtrTemplate<uint32_t, CFX_FontDescriptorInfos*> m_Hash2CandidateList; |
243 CFX_MapPtrTemplate<uint32_t, CFX_ArrayTemplate<IFGAS_Font*>*> m_Hash2Fonts; | 245 CFX_MapPtrTemplate<uint32_t, CFX_ArrayTemplate<CFGAS_GEFont*>*> m_Hash2Fonts; |
244 CFX_MapPtrTemplate<uint32_t, IFX_FileAccess*> m_Hash2FileAccess; | 246 CFX_MapPtrTemplate<uint32_t, IFX_FileAccess*> m_Hash2FileAccess; |
245 CFX_MapPtrTemplate<uint32_t, IFGAS_Font*> m_FileAccess2IFXFont; | 247 CFX_MapPtrTemplate<uint32_t, CFGAS_GEFont*> m_FileAccess2IFXFont; |
246 CFX_MapPtrTemplate<IFGAS_Font*, IFX_FileRead*> m_IFXFont2FileRead; | 248 CFX_MapPtrTemplate<CFGAS_GEFont*, IFX_FileRead*> m_IFXFont2FileRead; |
247 CFX_MapPtrTemplate<FX_WCHAR, IFGAS_Font*> m_FailedUnicodes2NULL; | 249 CFX_MapPtrTemplate<FX_WCHAR, CFGAS_GEFont*> m_FailedUnicodes2NULL; |
248 CFX_FontSourceEnum_File* const m_pFontSource; | 250 CFX_FontSourceEnum_File* const m_pFontSource; |
249 }; | 251 }; |
250 #endif | 252 #endif |
251 | 253 |
252 #endif // XFA_FGAS_FONT_FGAS_STDFONTMGR_H_ | 254 #endif // XFA_FGAS_FONT_FGAS_STDFONTMGR_H_ |
OLD | NEW |