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