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" |
(...skipping 27 matching lines...) Expand all Loading... |
38 uint32_t dwFontStyles, | 38 uint32_t dwFontStyles, |
39 const FX_WCHAR* pszFontFamily = NULL) override; | 39 const FX_WCHAR* pszFontFamily = NULL) override; |
40 CFGAS_GEFont* 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 CFGAS_GEFont* 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 CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, int32_t iLength) override; | 47 CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, int32_t iLength) override; |
48 CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFileName) override; | |
49 CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, | 48 CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, |
50 const FX_WCHAR* pszFontAlias = NULL, | 49 const FX_WCHAR* pszFontAlias = NULL, |
51 uint32_t dwFontStyles = 0, | 50 uint32_t dwFontStyles = 0, |
52 uint16_t wCodePage = 0, | 51 uint16_t wCodePage = 0, |
53 FX_BOOL bSaveStream = FALSE) override; | 52 FX_BOOL bSaveStream = FALSE) override; |
54 CFGAS_GEFont* LoadFont(CFGAS_GEFont* pSrcFont, | 53 CFGAS_GEFont* LoadFont(CFGAS_GEFont* pSrcFont, |
55 uint32_t dwFontStyles, | 54 uint32_t dwFontStyles, |
56 uint16_t wCodePage = 0xFFFF) override; | 55 uint16_t wCodePage = 0xFFFF) override; |
57 | 56 |
58 void ClearFontCache() override; | 57 void ClearFontCache() override; |
59 void RemoveFont(CFGAS_GEFont* pFont) override; | 58 void RemoveFont(CFGAS_GEFont* pFont) override; |
60 | 59 |
61 protected: | 60 protected: |
62 void RemoveFont(CFX_MapPtrToPtr& fontMap, CFGAS_GEFont* pFont); | 61 void RemoveFont(CFX_MapPtrToPtr& fontMap, CFGAS_GEFont* pFont); |
63 FX_FONTDESCRIPTOR const* FindFont(const FX_WCHAR* pszFontFamily, | 62 FX_FONTDESCRIPTOR const* FindFont(const FX_WCHAR* pszFontFamily, |
64 uint32_t dwFontStyles, | 63 uint32_t dwFontStyles, |
65 uint32_t dwMatchFlags, | 64 uint32_t dwMatchFlags, |
66 uint16_t wCodePage, | 65 uint16_t wCodePage, |
67 uint32_t dwUSB = 999, | 66 uint32_t dwUSB = 999, |
68 FX_WCHAR wUnicode = 0); | 67 FX_WCHAR wUnicode = 0); |
69 CFGAS_GEFont* GetFont(FX_FONTDESCRIPTOR const* pFD, uint32_t dwFontStyles); | 68 CFGAS_GEFont* GetFont(FX_FONTDESCRIPTOR const* pFD, uint32_t dwFontStyles); |
70 | 69 |
71 FX_LPEnumAllFonts m_pEnumerator; | 70 FX_LPEnumAllFonts m_pEnumerator; |
72 CFX_FontDescriptors m_FontFaces; | 71 CFX_FontDescriptors m_FontFaces; |
73 CFX_ArrayTemplate<CFGAS_GEFont*> m_Fonts; | 72 CFX_ArrayTemplate<CFGAS_GEFont*> m_Fonts; |
74 CFX_MapPtrToPtr m_CPFonts; | 73 CFX_MapPtrToPtr m_CPFonts; |
75 CFX_MapPtrToPtr m_FamilyFonts; | 74 CFX_MapPtrToPtr m_FamilyFonts; |
76 CFX_MapPtrToPtr m_UnicodeFonts; | 75 CFX_MapPtrToPtr m_UnicodeFonts; |
77 CFX_MapPtrToPtr m_BufferFonts; | 76 CFX_MapPtrToPtr m_BufferFonts; |
78 CFX_MapPtrToPtr m_FileFonts; | |
79 CFX_MapPtrToPtr m_StreamFonts; | 77 CFX_MapPtrToPtr m_StreamFonts; |
80 CFX_MapPtrToPtr m_DeriveFonts; | 78 CFX_MapPtrToPtr m_DeriveFonts; |
81 }; | 79 }; |
82 uint32_t FX_GetGdiFontStyles(const LOGFONTW& lf); | 80 uint32_t FX_GetGdiFontStyles(const LOGFONTW& lf); |
83 | 81 |
84 #else | 82 #else |
85 | 83 |
86 class CFX_FontDescriptor { | 84 class CFX_FontDescriptor { |
87 public: | 85 public: |
88 CFX_FontDescriptor() | 86 CFX_FontDescriptor() : m_nFaceIndex(0), m_dwFontStyles(0) { |
89 : m_pFileAccess(NULL), m_nFaceIndex(0), m_dwFontStyles(0) { | |
90 m_dwUsb[0] = m_dwUsb[1] = m_dwUsb[2] = m_dwUsb[3] = 0; | 87 m_dwUsb[0] = m_dwUsb[1] = m_dwUsb[2] = m_dwUsb[3] = 0; |
91 m_dwCsb[0] = m_dwCsb[1] = 0; | 88 m_dwCsb[0] = m_dwCsb[1] = 0; |
92 } | 89 } |
93 ~CFX_FontDescriptor() { | 90 ~CFX_FontDescriptor() {} |
94 if (NULL != m_pFileAccess) { | 91 |
95 m_pFileAccess->Release(); | |
96 } | |
97 } | |
98 IFX_FileAccess* m_pFileAccess; | |
99 int32_t m_nFaceIndex; | 92 int32_t m_nFaceIndex; |
100 CFX_WideString m_wsFaceName; | 93 CFX_WideString m_wsFaceName; |
101 CFX_WideStringArray m_wsFamilyNames; | 94 CFX_WideStringArray m_wsFamilyNames; |
102 uint32_t m_dwFontStyles; | 95 uint32_t m_dwFontStyles; |
103 uint32_t m_dwUsb[4]; | 96 uint32_t m_dwUsb[4]; |
104 uint32_t m_dwCsb[2]; | 97 uint32_t m_dwCsb[2]; |
105 }; | 98 }; |
106 typedef CFX_ArrayTemplate<CFX_FontDescriptor*> CFX_FontDescriptors; | 99 typedef CFX_ArrayTemplate<CFX_FontDescriptor*> CFX_FontDescriptors; |
107 | 100 |
108 struct FX_FontDescriptorInfo { | 101 struct FX_FontDescriptorInfo { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 CFGAS_GEFont* GetFontByCharset(uint8_t nCharset, | 171 CFGAS_GEFont* GetFontByCharset(uint8_t nCharset, |
179 uint32_t dwFontStyles, | 172 uint32_t dwFontStyles, |
180 const FX_WCHAR* pszFontFamily = NULL) override; | 173 const FX_WCHAR* pszFontFamily = NULL) override; |
181 CFGAS_GEFont* GetFontByUnicode(FX_WCHAR wUnicode, | 174 CFGAS_GEFont* GetFontByUnicode(FX_WCHAR wUnicode, |
182 uint32_t dwFontStyles, | 175 uint32_t dwFontStyles, |
183 const FX_WCHAR* pszFontFamily = NULL) override; | 176 const FX_WCHAR* pszFontFamily = NULL) override; |
184 CFGAS_GEFont* GetFontByLanguage( | 177 CFGAS_GEFont* GetFontByLanguage( |
185 uint16_t wLanguage, | 178 uint16_t wLanguage, |
186 uint32_t dwFontStyles, | 179 uint32_t dwFontStyles, |
187 const FX_WCHAR* pszFontFamily = NULL) override; | 180 const FX_WCHAR* pszFontFamily = NULL) override; |
188 CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, | |
189 int32_t iLength, | |
190 int32_t iFaceIndex, | |
191 int32_t* pFaceCount) override; | |
192 CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFileName, | |
193 int32_t iFaceIndex, | |
194 int32_t* pFaceCount) override; | |
195 CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, | |
196 int32_t iFaceIndex, | |
197 int32_t* pFaceCount, | |
198 FX_BOOL bSaveStream = FALSE) override; | |
199 void ClearFontCache() override; | 181 void ClearFontCache() override; |
200 void RemoveFont(CFGAS_GEFont* pFont) override; | 182 void RemoveFont(CFGAS_GEFont* pFont) override; |
201 | 183 |
202 CFGAS_GEFont* LoadFont(const CFX_WideString& wsFaceName, | 184 CFGAS_GEFont* LoadFont(const CFX_WideString& wsFaceName, |
203 int32_t iFaceIndex, | 185 int32_t iFaceIndex, |
204 int32_t* pFaceCount); | 186 int32_t* pFaceCount); |
205 FX_BOOL EnumFonts(); | 187 FX_BOOL EnumFonts(); |
206 FX_BOOL EnumFontsFromFontMapper(); | 188 FX_BOOL EnumFontsFromFontMapper(); |
207 FX_BOOL EnumFontsFromFiles(); | 189 FX_BOOL EnumFontsFromFiles(); |
208 | 190 |
209 protected: | 191 protected: |
210 void RegisterFace(FXFT_Face pFace, | 192 void RegisterFace(FXFT_Face pFace, |
211 CFX_FontDescriptors& Fonts, | 193 CFX_FontDescriptors& Fonts, |
212 const CFX_WideString* pFaceName, | 194 const CFX_WideString* pFaceName); |
213 IFX_FileAccess* pFontAccess); | |
214 void RegisterFaces(IFX_FileRead* pFontStream, | 195 void RegisterFaces(IFX_FileRead* pFontStream, |
215 const CFX_WideString* pFaceName); | 196 const CFX_WideString* pFaceName); |
216 void GetNames(const uint8_t* name_table, CFX_WideStringArray& Names); | 197 void GetNames(const uint8_t* name_table, CFX_WideStringArray& Names); |
217 void GetCharsets(FXFT_Face pFace, CFX_ArrayTemplate<uint16_t>& Charsets); | 198 void GetCharsets(FXFT_Face pFace, CFX_ArrayTemplate<uint16_t>& Charsets); |
218 void GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB); | 199 void GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB); |
219 uint32_t GetFlags(FXFT_Face pFace); | 200 uint32_t GetFlags(FXFT_Face pFace); |
220 CFX_FontDescriptors m_InstalledFonts; | 201 CFX_FontDescriptors m_InstalledFonts; |
221 FX_BOOL VerifyUnicode(CFX_FontDescriptor* pDesc, FX_WCHAR wcUnicode); | 202 FX_BOOL VerifyUnicode(CFX_FontDescriptor* pDesc, FX_WCHAR wcUnicode); |
222 FX_BOOL VerifyUnicode(CFGAS_GEFont* pFont, FX_WCHAR wcUnicode); | 203 FX_BOOL VerifyUnicode(CFGAS_GEFont* pFont, FX_WCHAR wcUnicode); |
223 int32_t IsPartName(const CFX_WideString& Name1, const CFX_WideString& Name2); | 204 int32_t IsPartName(const CFX_WideString& Name1, const CFX_WideString& Name2); |
224 int32_t MatchFonts(CFX_FontDescriptorInfos& MatchedFonts, | 205 int32_t MatchFonts(CFX_FontDescriptorInfos& MatchedFonts, |
225 uint16_t wCodePage, | 206 uint16_t wCodePage, |
226 uint32_t dwFontStyles, | 207 uint32_t dwFontStyles, |
227 const CFX_WideString& FontName, | 208 const CFX_WideString& FontName, |
228 FX_WCHAR wcUnicode = 0xFFFE); | 209 FX_WCHAR wcUnicode = 0xFFFE); |
229 int32_t CalcPenalty(CFX_FontDescriptor* pInstalled, | 210 int32_t CalcPenalty(CFX_FontDescriptor* pInstalled, |
230 uint16_t wCodePage, | 211 uint16_t wCodePage, |
231 uint32_t dwFontStyles, | 212 uint32_t dwFontStyles, |
232 const CFX_WideString& FontName, | 213 const CFX_WideString& FontName, |
233 FX_WCHAR wcUnicode = 0xFFFE); | 214 FX_WCHAR wcUnicode = 0xFFFE); |
234 CFGAS_GEFont* LoadFont(IFX_FileAccess* pFontAccess, | |
235 int32_t iFaceIndex, | |
236 int32_t* pFaceCount, | |
237 FX_BOOL bWantCache = FALSE); | |
238 FXFT_Face LoadFace(IFX_FileRead* pFontStream, int32_t iFaceIndex); | 215 FXFT_Face LoadFace(IFX_FileRead* pFontStream, int32_t iFaceIndex); |
239 IFX_FileRead* CreateFontStream(CFX_FontMapper* pFontMapper, | 216 IFX_FileRead* CreateFontStream(CFX_FontMapper* pFontMapper, |
240 IFX_SystemFontInfo* pSystemFontInfo, | 217 IFX_SystemFontInfo* pSystemFontInfo, |
241 uint32_t index); | 218 uint32_t index); |
242 IFX_FileRead* CreateFontStream(const CFX_ByteString& bsFaceName); | 219 IFX_FileRead* CreateFontStream(const CFX_ByteString& bsFaceName); |
243 | 220 |
244 CFX_MapPtrTemplate<uint32_t, CFX_FontDescriptorInfos*> m_Hash2CandidateList; | 221 CFX_MapPtrTemplate<uint32_t, CFX_FontDescriptorInfos*> m_Hash2CandidateList; |
245 CFX_MapPtrTemplate<uint32_t, CFX_ArrayTemplate<CFGAS_GEFont*>*> m_Hash2Fonts; | 222 CFX_MapPtrTemplate<uint32_t, CFX_ArrayTemplate<CFGAS_GEFont*>*> m_Hash2Fonts; |
246 CFX_MapPtrTemplate<uint32_t, IFX_FileAccess*> m_Hash2FileAccess; | |
247 CFX_MapPtrTemplate<uint32_t, CFGAS_GEFont*> m_FileAccess2IFXFont; | |
248 CFX_MapPtrTemplate<CFGAS_GEFont*, IFX_FileRead*> m_IFXFont2FileRead; | 223 CFX_MapPtrTemplate<CFGAS_GEFont*, IFX_FileRead*> m_IFXFont2FileRead; |
249 CFX_MapPtrTemplate<FX_WCHAR, CFGAS_GEFont*> m_FailedUnicodes2NULL; | 224 CFX_MapPtrTemplate<FX_WCHAR, CFGAS_GEFont*> m_FailedUnicodes2NULL; |
250 CFX_FontSourceEnum_File* const m_pFontSource; | 225 CFX_FontSourceEnum_File* const m_pFontSource; |
251 }; | 226 }; |
252 #endif | 227 #endif |
253 | 228 |
254 #endif // XFA_FGAS_FONT_FGAS_STDFONTMGR_H_ | 229 #endif // XFA_FGAS_FONT_FGAS_STDFONTMGR_H_ |
OLD | NEW |