| 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_CFGAS_FONTMGR_H_ | 7 #ifndef XFA_FGAS_FONT_CFGAS_FONTMGR_H_ |
| 8 #define XFA_FGAS_FONT_CFGAS_FONTMGR_H_ | 8 #define XFA_FGAS_FONT_CFGAS_FONTMGR_H_ |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 FX_LPEnumAllFonts FX_GetDefFontEnumerator(); | 87 FX_LPEnumAllFonts FX_GetDefFontEnumerator(); |
| 88 | 88 |
| 89 class CFGAS_FontMgr { | 89 class CFGAS_FontMgr { |
| 90 public: | 90 public: |
| 91 explicit CFGAS_FontMgr(FX_LPEnumAllFonts pEnumerator); | 91 explicit CFGAS_FontMgr(FX_LPEnumAllFonts pEnumerator); |
| 92 ~CFGAS_FontMgr(); | 92 ~CFGAS_FontMgr(); |
| 93 | 93 |
| 94 static std::unique_ptr<CFGAS_FontMgr> Create(FX_LPEnumAllFonts pEnumerator); | 94 static std::unique_ptr<CFGAS_FontMgr> Create(FX_LPEnumAllFonts pEnumerator); |
| 95 | 95 |
| 96 CFGAS_GEFont* GetDefFontByCodePage(uint16_t wCodePage, | 96 CFGAS_GEFont* GetFontByCodePage(uint16_t wCodePage, |
| 97 uint32_t dwFontStyles, | 97 uint32_t dwFontStyles, |
| 98 const FX_WCHAR* pszFontFamily = nullptr); | 98 const FX_WCHAR* pszFontFamily); |
| 99 CFGAS_GEFont* GetDefFontByUnicode(FX_WCHAR wUnicode, | 99 CFGAS_GEFont* GetFontByUnicode(FX_WCHAR wUnicode, |
| 100 uint32_t dwFontStyles, | 100 uint32_t dwFontStyles, |
| 101 const FX_WCHAR* pszFontFamily = nullptr); | 101 const FX_WCHAR* pszFontFamily); |
| 102 CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, | 102 CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, |
| 103 uint32_t dwFontStyles, | 103 uint32_t dwFontStyles, |
| 104 uint16_t wCodePage = 0xFFFF); | 104 uint16_t wCodePage); |
| 105 CFGAS_GEFont* LoadFont(const uint8_t* pBuffer, int32_t iLength); | |
| 106 CFGAS_GEFont* LoadFont(IFX_Stream* pFontStream, | |
| 107 const FX_WCHAR* pszFontAlias = nullptr, | |
| 108 uint32_t dwFontStyles = 0, | |
| 109 uint16_t wCodePage = 0, | |
| 110 bool bSaveStream = false); | |
| 111 CFGAS_GEFont* LoadFont(CFGAS_GEFont* pSrcFont, | |
| 112 uint32_t dwFontStyles, | |
| 113 uint16_t wCodePage = 0xFFFF); | |
| 114 | |
| 115 // TODO(npm): This method is not being used, but probably should be in | |
| 116 // destructor | |
| 117 void ClearFontCache(); | |
| 118 void RemoveFont(CFGAS_GEFont* pFont); | 105 void RemoveFont(CFGAS_GEFont* pFont); |
| 119 | 106 |
| 120 private: | 107 private: |
| 108 CFGAS_GEFont* LoadFont(CFGAS_GEFont* pSrcFont, |
| 109 uint32_t dwFontStyles, |
| 110 uint16_t wCodePage); |
| 121 void RemoveFont(CFX_MapPtrToPtr& fontMap, CFGAS_GEFont* pFont); | 111 void RemoveFont(CFX_MapPtrToPtr& fontMap, CFGAS_GEFont* pFont); |
| 122 FX_FONTDESCRIPTOR const* FindFont(const FX_WCHAR* pszFontFamily, | 112 FX_FONTDESCRIPTOR const* FindFont(const FX_WCHAR* pszFontFamily, |
| 123 uint32_t dwFontStyles, | 113 uint32_t dwFontStyles, |
| 124 uint32_t dwMatchFlags, | 114 uint32_t dwMatchFlags, |
| 125 uint16_t wCodePage, | 115 uint16_t wCodePage, |
| 126 uint32_t dwUSB = 999, | 116 uint32_t dwUSB = 999, |
| 127 FX_WCHAR wUnicode = 0); | 117 FX_WCHAR wUnicode = 0); |
| 128 | 118 |
| 129 FX_LPEnumAllFonts m_pEnumerator; | 119 FX_LPEnumAllFonts m_pEnumerator; |
| 130 CFX_FontDescriptors m_FontFaces; | 120 CFX_FontDescriptors m_FontFaces; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 ~CFGAS_FontMgr(); | 193 ~CFGAS_FontMgr(); |
| 204 static std::unique_ptr<CFGAS_FontMgr> Create( | 194 static std::unique_ptr<CFGAS_FontMgr> Create( |
| 205 CFX_FontSourceEnum_File* pFontEnum); | 195 CFX_FontSourceEnum_File* pFontEnum); |
| 206 | 196 |
| 207 CFGAS_GEFont* GetFontByCodePage(uint16_t wCodePage, | 197 CFGAS_GEFont* GetFontByCodePage(uint16_t wCodePage, |
| 208 uint32_t dwFontStyles, | 198 uint32_t dwFontStyles, |
| 209 const FX_WCHAR* pszFontFamily); | 199 const FX_WCHAR* pszFontFamily); |
| 210 CFGAS_GEFont* GetFontByUnicode(FX_WCHAR wUnicode, | 200 CFGAS_GEFont* GetFontByUnicode(FX_WCHAR wUnicode, |
| 211 uint32_t dwFontStyles, | 201 uint32_t dwFontStyles, |
| 212 const FX_WCHAR* pszFontFamily); | 202 const FX_WCHAR* pszFontFamily); |
| 213 void ClearFontCache(); | |
| 214 void RemoveFont(CFGAS_GEFont* pFont); | 203 void RemoveFont(CFGAS_GEFont* pFont); |
| 215 | 204 |
| 216 CFGAS_GEFont* LoadFont(const CFX_WideString& wsFaceName, | |
| 217 int32_t iFaceIndex, | |
| 218 int32_t* pFaceCount); | |
| 219 inline CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, | 205 inline CFGAS_GEFont* LoadFont(const FX_WCHAR* pszFontFamily, |
| 220 uint32_t dwFontStyles, | 206 uint32_t dwFontStyles, |
| 221 uint16_t wCodePage) { | 207 uint16_t wCodePage) { |
| 222 return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); | 208 return GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); |
| 223 } | 209 } |
| 210 |
| 211 private: |
| 224 bool EnumFonts(); | 212 bool EnumFonts(); |
| 225 bool EnumFontsFromFontMapper(); | 213 bool EnumFontsFromFontMapper(); |
| 226 bool EnumFontsFromFiles(); | 214 bool EnumFontsFromFiles(); |
| 227 | |
| 228 private: | |
| 229 void RegisterFace(FXFT_Face pFace, const CFX_WideString* pFaceName); | 215 void RegisterFace(FXFT_Face pFace, const CFX_WideString* pFaceName); |
| 230 void RegisterFaces(IFX_SeekableReadStream* pFontStream, | 216 void RegisterFaces(IFX_SeekableReadStream* pFontStream, |
| 231 const CFX_WideString* pFaceName); | 217 const CFX_WideString* pFaceName); |
| 232 void GetNames(const uint8_t* name_table, CFX_WideStringArray& Names); | 218 void GetNames(const uint8_t* name_table, CFX_WideStringArray& Names); |
| 233 std::vector<uint16_t> GetCharsets(FXFT_Face pFace) const; | 219 std::vector<uint16_t> GetCharsets(FXFT_Face pFace) const; |
| 234 void GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB); | 220 void GetUSBCSB(FXFT_Face pFace, uint32_t* USB, uint32_t* CSB); |
| 235 uint32_t GetFlags(FXFT_Face pFace); | 221 uint32_t GetFlags(FXFT_Face pFace); |
| 236 bool VerifyUnicode(CFX_FontDescriptor* pDesc, FX_WCHAR wcUnicode); | 222 bool VerifyUnicode(CFX_FontDescriptor* pDesc, FX_WCHAR wcUnicode); |
| 237 bool VerifyUnicode(CFGAS_GEFont* pFont, FX_WCHAR wcUnicode); | 223 bool VerifyUnicode(CFGAS_GEFont* pFont, FX_WCHAR wcUnicode); |
| 238 int32_t IsPartName(const CFX_WideString& Name1, const CFX_WideString& Name2); | 224 int32_t IsPartName(const CFX_WideString& Name1, const CFX_WideString& Name2); |
| 239 int32_t MatchFonts(CFX_FontDescriptorInfos& MatchedFonts, | 225 int32_t MatchFonts(CFX_FontDescriptorInfos& MatchedFonts, |
| 240 uint16_t wCodePage, | 226 uint16_t wCodePage, |
| 241 uint32_t dwFontStyles, | 227 uint32_t dwFontStyles, |
| 242 const CFX_WideString& FontName, | 228 const CFX_WideString& FontName, |
| 243 FX_WCHAR wcUnicode = 0xFFFE); | 229 FX_WCHAR wcUnicode = 0xFFFE); |
| 244 int32_t CalcPenalty(CFX_FontDescriptor* pInstalled, | 230 int32_t CalcPenalty(CFX_FontDescriptor* pInstalled, |
| 245 uint16_t wCodePage, | 231 uint16_t wCodePage, |
| 246 uint32_t dwFontStyles, | 232 uint32_t dwFontStyles, |
| 247 const CFX_WideString& FontName, | 233 const CFX_WideString& FontName, |
| 248 FX_WCHAR wcUnicode = 0xFFFE); | 234 FX_WCHAR wcUnicode = 0xFFFE); |
| 235 CFGAS_GEFont* LoadFont(const CFX_WideString& wsFaceName, |
| 236 int32_t iFaceIndex, |
| 237 int32_t* pFaceCount); |
| 249 FXFT_Face LoadFace(IFX_SeekableReadStream* pFontStream, int32_t iFaceIndex); | 238 FXFT_Face LoadFace(IFX_SeekableReadStream* pFontStream, int32_t iFaceIndex); |
| 250 IFX_SeekableReadStream* CreateFontStream(CFX_FontMapper* pFontMapper, | 239 IFX_SeekableReadStream* CreateFontStream(CFX_FontMapper* pFontMapper, |
| 251 IFX_SystemFontInfo* pSystemFontInfo, | 240 IFX_SystemFontInfo* pSystemFontInfo, |
| 252 uint32_t index); | 241 uint32_t index); |
| 253 IFX_SeekableReadStream* CreateFontStream(const CFX_ByteString& bsFaceName); | 242 IFX_SeekableReadStream* CreateFontStream(const CFX_ByteString& bsFaceName); |
| 254 | 243 |
| 255 CFX_FontDescriptors m_InstalledFonts; | 244 CFX_FontDescriptors m_InstalledFonts; |
| 256 CFX_MapPtrTemplate<uint32_t, CFX_FontDescriptorInfos*> m_Hash2CandidateList; | 245 CFX_MapPtrTemplate<uint32_t, CFX_FontDescriptorInfos*> m_Hash2CandidateList; |
| 257 CFX_MapPtrTemplate<uint32_t, CFX_ArrayTemplate<CFGAS_GEFont*>*> m_Hash2Fonts; | 246 CFX_MapPtrTemplate<uint32_t, CFX_ArrayTemplate<CFGAS_GEFont*>*> m_Hash2Fonts; |
| 258 CFX_MapPtrTemplate<CFGAS_GEFont*, IFX_SeekableReadStream*> m_IFXFont2FileRead; | 247 CFX_MapPtrTemplate<CFGAS_GEFont*, IFX_SeekableReadStream*> m_IFXFont2FileRead; |
| 259 CFX_MapPtrTemplate<FX_WCHAR, CFGAS_GEFont*> m_FailedUnicodes2Nullptr; | 248 CFX_MapPtrTemplate<FX_WCHAR, CFGAS_GEFont*> m_FailedUnicodes2Nullptr; |
| 260 CFX_FontSourceEnum_File* const m_pFontSource; | 249 CFX_FontSourceEnum_File* const m_pFontSource; |
| 261 }; | 250 }; |
| 262 #endif | 251 #endif |
| 263 | 252 |
| 264 #endif // XFA_FGAS_FONT_CFGAS_FONTMGR_H_ | 253 #endif // XFA_FGAS_FONT_CFGAS_FONTMGR_H_ |
| OLD | NEW |