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