| 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 "core/fxge/include/fx_ge.h" | 12 #include "core/fxge/include/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, uint32_t dwFontStyles); | 17 int32_t FX_GetSimilarValue(FX_LPCFONTDESCRIPTOR pFont, uint32_t 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); | |
| 21 | 20 |
| 22 class CFX_StdFontMgrImp : public IFX_FontMgr { | 21 class CFX_StdFontMgrImp : public IFX_FontMgr { |
| 23 public: | 22 public: |
| 24 CFX_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator, | 23 CFX_StdFontMgrImp(FX_LPEnumAllFonts pEnumerator); |
| 25 FX_LPMatchFont pMatcher, | |
| 26 void* pUserData); | |
| 27 ~CFX_StdFontMgrImp(); | 24 ~CFX_StdFontMgrImp(); |
| 28 virtual void Release() { delete this; } | 25 virtual void Release() { delete this; } |
| 29 virtual IFX_Font* GetDefFontByCodePage(uint16_t wCodePage, | 26 virtual IFX_Font* GetDefFontByCodePage(uint16_t wCodePage, |
| 30 uint32_t dwFontStyles, | 27 uint32_t dwFontStyles, |
| 31 const FX_WCHAR* pszFontFamily = NULL); | 28 const FX_WCHAR* pszFontFamily = NULL); |
| 32 virtual IFX_Font* GetDefFontByCharset(uint8_t nCharset, | 29 virtual IFX_Font* GetDefFontByCharset(uint8_t nCharset, |
| 33 uint32_t dwFontStyles, | 30 uint32_t dwFontStyles, |
| 34 const FX_WCHAR* pszFontFamily = NULL); | 31 const FX_WCHAR* pszFontFamily = NULL); |
| 35 virtual IFX_Font* GetDefFontByUnicode(FX_WCHAR wUnicode, | 32 virtual IFX_Font* GetDefFontByUnicode(FX_WCHAR wUnicode, |
| 36 uint32_t dwFontStyles, | 33 uint32_t dwFontStyles, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 48 uint32_t dwFontStyles = 0, | 45 uint32_t dwFontStyles = 0, |
| 49 uint16_t wCodePage = 0, | 46 uint16_t wCodePage = 0, |
| 50 FX_BOOL bSaveStream = FALSE); | 47 FX_BOOL bSaveStream = FALSE); |
| 51 virtual IFX_Font* LoadFont(IFX_Font* pSrcFont, | 48 virtual IFX_Font* LoadFont(IFX_Font* pSrcFont, |
| 52 uint32_t dwFontStyles, | 49 uint32_t dwFontStyles, |
| 53 uint16_t wCodePage = 0xFFFF); | 50 uint16_t wCodePage = 0xFFFF); |
| 54 virtual void ClearFontCache(); | 51 virtual void ClearFontCache(); |
| 55 virtual void RemoveFont(IFX_Font* pFont); | 52 virtual void RemoveFont(IFX_Font* pFont); |
| 56 | 53 |
| 57 protected: | 54 protected: |
| 58 FX_LPMatchFont m_pMatcher; | 55 void RemoveFont(CFX_MapPtrToPtr& fontMap, IFX_Font* pFont); |
| 56 FX_LPCFONTDESCRIPTOR FindFont(const FX_WCHAR* pszFontFamily, |
| 57 uint32_t dwFontStyles, |
| 58 uint32_t dwMatchFlags, |
| 59 uint16_t wCodePage, |
| 60 uint32_t dwUSB = 999, |
| 61 FX_WCHAR wUnicode = 0); |
| 62 IFX_Font* GetFont(FX_LPCFONTDESCRIPTOR pFD, uint32_t dwFontStyles); |
| 63 |
| 59 FX_LPEnumAllFonts m_pEnumerator; | 64 FX_LPEnumAllFonts m_pEnumerator; |
| 60 CFX_FontDescriptors m_FontFaces; | 65 CFX_FontDescriptors m_FontFaces; |
| 61 CFX_PtrArray m_Fonts; | 66 CFX_PtrArray m_Fonts; |
| 62 CFX_MapPtrToPtr m_CPFonts; | 67 CFX_MapPtrToPtr m_CPFonts; |
| 63 CFX_MapPtrToPtr m_FamilyFonts; | 68 CFX_MapPtrToPtr m_FamilyFonts; |
| 64 CFX_MapPtrToPtr m_UnicodeFonts; | 69 CFX_MapPtrToPtr m_UnicodeFonts; |
| 65 CFX_MapPtrToPtr m_BufferFonts; | 70 CFX_MapPtrToPtr m_BufferFonts; |
| 66 CFX_MapPtrToPtr m_FileFonts; | 71 CFX_MapPtrToPtr m_FileFonts; |
| 67 CFX_MapPtrToPtr m_StreamFonts; | 72 CFX_MapPtrToPtr m_StreamFonts; |
| 68 CFX_MapPtrToPtr m_DeriveFonts; | 73 CFX_MapPtrToPtr m_DeriveFonts; |
| 69 void* m_pUserData; | |
| 70 void RemoveFont(CFX_MapPtrToPtr& fontMap, IFX_Font* pFont); | |
| 71 FX_LPCFONTDESCRIPTOR FindFont(const FX_WCHAR* pszFontFamily, | |
| 72 uint32_t dwFontStyles, | |
| 73 uint32_t dwMatchFlags, | |
| 74 uint16_t wCodePage, | |
| 75 uint32_t dwUSB = 999, | |
| 76 FX_WCHAR wUnicode = 0); | |
| 77 IFX_Font* GetFont(FX_LPCFONTDESCRIPTOR pFD, uint32_t dwFontStyles); | |
| 78 }; | 74 }; |
| 79 uint32_t FX_GetGdiFontStyles(const LOGFONTW& lf); | 75 uint32_t FX_GetGdiFontStyles(const LOGFONTW& lf); |
| 80 | 76 |
| 81 #else | 77 #else |
| 82 | 78 |
| 83 class CFX_FontDescriptor { | 79 class CFX_FontDescriptor { |
| 84 public: | 80 public: |
| 85 CFX_FontDescriptor() | 81 CFX_FontDescriptor() |
| 86 : m_pFileAccess(NULL), m_nFaceIndex(0), m_dwFontStyles(0) { | 82 : m_pFileAccess(NULL), m_nFaceIndex(0), m_dwFontStyles(0) { |
| 87 m_dwUsb[0] = m_dwUsb[1] = m_dwUsb[2] = m_dwUsb[3] = 0; | 83 m_dwUsb[0] = m_dwUsb[1] = m_dwUsb[2] = m_dwUsb[3] = 0; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 bsParentPath = x.bsParentPath; | 122 bsParentPath = x.bsParentPath; |
| 127 } | 123 } |
| 128 void* pFileHandle; | 124 void* pFileHandle; |
| 129 CFX_ByteString bsParentPath; | 125 CFX_ByteString bsParentPath; |
| 130 }; | 126 }; |
| 131 | 127 |
| 132 class CFX_FontSourceEnum_File : public IFX_FontSourceEnum { | 128 class CFX_FontSourceEnum_File : public IFX_FontSourceEnum { |
| 133 public: | 129 public: |
| 134 CFX_FontSourceEnum_File(); | 130 CFX_FontSourceEnum_File(); |
| 135 virtual void Release() { delete this; } | 131 virtual void Release() { delete this; } |
| 136 virtual FX_POSITION GetStartPosition(void* pUserData = NULL); | 132 virtual FX_POSITION GetStartPosition(); |
| 137 virtual IFX_FileAccess* GetNext(FX_POSITION& pos, void* pUserData = NULL); | 133 virtual IFX_FileAccess* GetNext(FX_POSITION& pos); |
| 138 | 134 |
| 139 private: | 135 private: |
| 140 CFX_ByteString GetNextFile(); | 136 CFX_ByteString GetNextFile(); |
| 141 CFX_WideString m_wsNext; | 137 CFX_WideString m_wsNext; |
| 142 CFX_ObjectArray<FX_HandleParentPath> m_FolderQueue; | 138 CFX_ObjectArray<FX_HandleParentPath> m_FolderQueue; |
| 143 CFX_ByteStringArray m_FolderPaths; | 139 CFX_ByteStringArray m_FolderPaths; |
| 144 }; | 140 }; |
| 145 typedef CFX_MapPtrTemplate<uint32_t, IFX_FileAccess*> CFX_HashFileMap; | 141 typedef CFX_MapPtrTemplate<uint32_t, IFX_FileAccess*> CFX_HashFileMap; |
| 146 typedef CFX_MapPtrTemplate<uint32_t, IFX_Font*> CFX_HashFontMap; | 142 typedef CFX_MapPtrTemplate<uint32_t, IFX_Font*> CFX_HashFontMap; |
| 147 typedef CFX_MapPtrTemplate<uint32_t, CFX_FontDescriptorInfos*> | 143 typedef CFX_MapPtrTemplate<uint32_t, CFX_FontDescriptorInfos*> |
| 148 CFX_HashFontDescsMap; | 144 CFX_HashFontDescsMap; |
| 149 typedef CFX_MapPtrTemplate<uint32_t, CFX_ArrayTemplate<IFX_Font*>*> | 145 typedef CFX_MapPtrTemplate<uint32_t, CFX_ArrayTemplate<IFX_Font*>*> |
| 150 CFX_HashFontsMap; | 146 CFX_HashFontsMap; |
| 151 typedef CFX_MapPtrTemplate<FX_WCHAR, IFX_Font*> CFX_UnicodeFontMap; | 147 typedef CFX_MapPtrTemplate<FX_WCHAR, IFX_Font*> CFX_UnicodeFontMap; |
| 152 typedef CFX_MapPtrTemplate<IFX_FileAccess*, CFX_ArrayTemplate<IFX_Font*>*> | 148 typedef CFX_MapPtrTemplate<IFX_FileAccess*, CFX_ArrayTemplate<IFX_Font*>*> |
| 153 CFX_FileFontMap; | 149 CFX_FileFontMap; |
| 154 typedef CFX_MapPtrTemplate<IFX_Font*, IFX_FileRead*> CFX_FonStreamtMap; | 150 typedef CFX_MapPtrTemplate<IFX_Font*, IFX_FileRead*> CFX_FonStreamtMap; |
| 155 | 151 |
| 156 class CFX_FontMgrImp : public IFX_FontMgr { | 152 class CFX_FontMgrImp : public IFX_FontMgr { |
| 157 public: | 153 public: |
| 158 CFX_FontMgrImp(IFX_FontSourceEnum* pFontEnum, | 154 CFX_FontMgrImp(IFX_FontSourceEnum* pFontEnum); |
| 159 IFX_FontMgrDelegate* pDelegate = NULL, | |
| 160 void* pUserData = NULL); | |
| 161 virtual void Release(); | 155 virtual void Release(); |
| 162 virtual IFX_Font* GetDefFontByCodePage(uint16_t wCodePage, | 156 virtual IFX_Font* GetDefFontByCodePage(uint16_t wCodePage, |
| 163 uint32_t dwFontStyles, | 157 uint32_t dwFontStyles, |
| 164 const FX_WCHAR* pszFontFamily = NULL); | 158 const FX_WCHAR* pszFontFamily = NULL); |
| 165 virtual IFX_Font* GetDefFontByCharset(uint8_t nCharset, | 159 virtual IFX_Font* GetDefFontByCharset(uint8_t nCharset, |
| 166 uint32_t dwFontStyles, | 160 uint32_t dwFontStyles, |
| 167 const FX_WCHAR* pszFontFamily = NULL); | 161 const FX_WCHAR* pszFontFamily = NULL); |
| 168 virtual IFX_Font* GetDefFontByUnicode(FX_WCHAR wUnicode, | 162 virtual IFX_Font* GetDefFontByUnicode(FX_WCHAR wUnicode, |
| 169 uint32_t dwFontStyles, | 163 uint32_t dwFontStyles, |
| 170 const FX_WCHAR* pszFontFamily = NULL); | 164 const FX_WCHAR* pszFontFamily = NULL); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 FX_WCHAR wcUnicode = 0xFFFE); | 224 FX_WCHAR wcUnicode = 0xFFFE); |
| 231 IFX_Font* LoadFont(IFX_FileAccess* pFontAccess, | 225 IFX_Font* LoadFont(IFX_FileAccess* pFontAccess, |
| 232 int32_t iFaceIndex, | 226 int32_t iFaceIndex, |
| 233 int32_t* pFaceCount, | 227 int32_t* pFaceCount, |
| 234 FX_BOOL bWantCache = FALSE); | 228 FX_BOOL bWantCache = FALSE); |
| 235 FXFT_Face LoadFace(IFX_FileRead* pFontStream, int32_t iFaceIndex); | 229 FXFT_Face LoadFace(IFX_FileRead* pFontStream, int32_t iFaceIndex); |
| 236 IFX_FileRead* CreateFontStream(CFX_FontMapper* pFontMapper, | 230 IFX_FileRead* CreateFontStream(CFX_FontMapper* pFontMapper, |
| 237 IFX_SystemFontInfo* pSystemFontInfo, | 231 IFX_SystemFontInfo* pSystemFontInfo, |
| 238 uint32_t index); | 232 uint32_t index); |
| 239 IFX_FileRead* CreateFontStream(const CFX_ByteString& bsFaceName); | 233 IFX_FileRead* CreateFontStream(const CFX_ByteString& bsFaceName); |
| 234 |
| 240 CFX_HashFontDescsMap m_Hash2CandidateList; | 235 CFX_HashFontDescsMap m_Hash2CandidateList; |
| 241 CFX_HashFontsMap m_Hash2Fonts; | 236 CFX_HashFontsMap m_Hash2Fonts; |
| 242 CFX_HashFileMap m_Hash2FileAccess; | 237 CFX_HashFileMap m_Hash2FileAccess; |
| 243 CFX_HashFontMap m_FileAccess2IFXFont; | 238 CFX_HashFontMap m_FileAccess2IFXFont; |
| 244 CFX_FonStreamtMap m_IFXFont2FileRead; | 239 CFX_FonStreamtMap m_IFXFont2FileRead; |
| 245 CFX_UnicodeFontMap m_FailedUnicodes2NULL; | 240 CFX_UnicodeFontMap m_FailedUnicodes2NULL; |
| 246 IFX_FontSourceEnum* m_pFontSource; | 241 IFX_FontSourceEnum* m_pFontSource; |
| 247 IFX_FontMgrDelegate* m_pDelegate; | |
| 248 void* m_pUserData; | |
| 249 }; | 242 }; |
| 250 #endif | 243 #endif |
| 251 | 244 |
| 252 #endif // XFA_FGAS_FONT_FGAS_STDFONTMGR_H_ | 245 #endif // XFA_FGAS_FONT_FGAS_STDFONTMGR_H_ |
| OLD | NEW |