Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame^] | 1 | // Copyright 2017 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 XFA_FXFA_CXFA_PDFFONTMGR_H_ |
| 8 | #define XFA_FXFA_CXFA_PDFFONTMGR_H_ |
| 9 | |
| 10 | #include <map> |
| 11 | |
| 12 | #include "core/fpdfapi/parser/cpdf_dictionary.h" |
| 13 | #include "core/fpdfapi/parser/cpdf_document.h" |
| 14 | #include "core/fxcrt/cfx_retain_ptr.h" |
| 15 | #include "core/fxcrt/fx_string.h" |
| 16 | #include "xfa/fgas/font/cfgas_gefont.h" |
| 17 | #include "xfa/fxfa/cxfa_ffdoc.h" |
| 18 | |
| 19 | class CPDF_Font; |
| 20 | class CXFA_FFDoc; |
| 21 | |
| 22 | class CXFA_PDFFontMgr { |
| 23 | public: |
| 24 | explicit CXFA_PDFFontMgr(CXFA_FFDoc* pDoc); |
| 25 | ~CXFA_PDFFontMgr(); |
| 26 | |
| 27 | CFX_RetainPtr<CFGAS_GEFont> GetFont(const CFX_WideStringC& wsFontFamily, |
| 28 | uint32_t dwFontStyles, |
| 29 | CPDF_Font** pPDFFont, |
| 30 | bool bStrictMatch); |
| 31 | bool GetCharWidth(const CFX_RetainPtr<CFGAS_GEFont>& pFont, |
| 32 | wchar_t wUnicode, |
| 33 | bool bCharCode, |
| 34 | int32_t* pWidth); |
| 35 | void SetFont(const CFX_RetainPtr<CFGAS_GEFont>& pFont, CPDF_Font* pPDFFont); |
| 36 | |
| 37 | private: |
| 38 | CFX_RetainPtr<CFGAS_GEFont> FindFont(const CFX_ByteString& strFamilyName, |
| 39 | bool bBold, |
| 40 | bool bItalic, |
| 41 | CPDF_Font** pPDFFont, |
| 42 | bool bStrictMatch); |
| 43 | CFX_ByteString PsNameToFontName(const CFX_ByteString& strPsName, |
| 44 | bool bBold, |
| 45 | bool bItalic); |
| 46 | bool PsNameMatchDRFontName(const CFX_ByteStringC& bsPsName, |
| 47 | bool bBold, |
| 48 | bool bItalic, |
| 49 | const CFX_ByteString& bsDRFontName, |
| 50 | bool bStrictMatch); |
| 51 | |
| 52 | CXFA_FFDoc* const m_pDoc; |
| 53 | std::map<CFX_RetainPtr<CFGAS_GEFont>, CPDF_Font*> m_FDE2PDFFont; |
| 54 | std::map<CFX_ByteString, CFX_RetainPtr<CFGAS_GEFont>> m_FontMap; |
| 55 | }; |
| 56 | |
| 57 | #endif // XFA_FXFA_CXFA_PDFFONTMGR_H_ |