1 // Copyright 2014 PDFium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef _FXFA_FORMFILLER_FONTMGR_IMP_H 8 #define _FXFA_FORMFILLER_FONTMGR_IMP_H 9 struct XFA_FONTINFO { 10 FX_DWORD dwFontNameHash; 11 const FX_WCHAR* pPsName; 12 const FX_WCHAR* pReplaceFont; 13 FX_WORD dwStyles; 14 FX_WORD wCodePage; 15 }; 16 class CXFA_DefFontMgr : public IXFA_FontMgr { 17 public: CXFA_DefFontMgr()18 CXFA_DefFontMgr() {} 19 ~CXFA_DefFontMgr() override; 20 21 // IXFA_FontMgr: 22 IFX_Font* GetFont(IXFA_Doc* hDoc, 23 const CFX_WideStringC& wsFontFamily, 24 FX_DWORD dwFontStyles, 25 FX_WORD wCodePage = 0xFFFF) override; 26 IFX_Font* GetDefaultFont(IXFA_Doc* hDoc, 27 const CFX_WideStringC& wsFontFamily, 28 FX_DWORD dwFontStyles, 29 FX_WORD wCodePage = 0xFFFF) override; 30 31 protected: 32 CFX_PtrArray m_CacheFonts; 33 }; 34 class CXFA_PDFFontMgr : public IFX_FontProvider { 35 public: 36 CXFA_PDFFontMgr(CXFA_FFDoc* pDoc); 37 ~CXFA_PDFFontMgr(); 38 IFX_Font* GetFont(const CFX_WideStringC& wsFontFamily, 39 FX_DWORD dwFontStyles, 40 CPDF_Font** pPDFFont, 41 FX_BOOL bStrictMatch = TRUE); 42 FX_BOOL GetCharWidth(IFX_Font* pFont, 43 FX_WCHAR wUnicode, 44 int32_t& iWidth, 45 FX_BOOL bCharCode); 46 CFX_MapPtrToPtr m_FDE2PDFFont; 47 48 protected: 49 IFX_Font* FindFont(CFX_ByteString strFamilyName, 50 FX_BOOL bBold, 51 FX_BOOL bItalic, 52 CPDF_Font** pPDFFont, 53 FX_BOOL bStrictMatch = TRUE); 54 CFX_ByteString PsNameToFontName(const CFX_ByteString& strPsName, 55 FX_BOOL bBold, 56 FX_BOOL bItalic); 57 FX_BOOL PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName, 58 FX_BOOL bBold, 59 FX_BOOL bItalic, 60 const CFX_ByteString& bsDRFontName, 61 FX_BOOL bStrictMatch = TRUE); 62 CXFA_FFDoc* m_pDoc; 63 CFX_CMapByteStringToPtr m_FontArray; 64 }; 65 class CXFA_FontMgr { 66 public: 67 CXFA_FontMgr(); 68 ~CXFA_FontMgr(); 69 IFX_Font* GetFont(IXFA_Doc* hDoc, 70 const CFX_WideStringC& wsFontFamily, 71 FX_DWORD dwFontStyles, 72 FX_WORD wCodePage = 0xFFFF); 73 void LoadDocFonts(IXFA_Doc* hDoc); 74 void ReleaseDocFonts(IXFA_Doc* hDoc); 75 76 void SetDefFontMgr(IXFA_FontMgr* pFontMgr); 77 78 protected: 79 void DelAllMgrMap(); 80 CFX_MapPtrToPtr m_PDFFontMgrArray; 81 IXFA_FontMgr* m_pDefFontMgr; 82 CFX_CMapByteStringToPtr m_FontArray; 83 }; 84 #endif 85