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