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_FGAS_FONT_CFGAS_PDFFONTMGR_H_ 8 #define XFA_FGAS_FONT_CFGAS_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/fx_string.h" 15 #include "core/fxcrt/observable.h" 16 #include "core/fxcrt/retain_ptr.h" 17 18 class CFGAS_FontMgr; 19 class CFGAS_GEFont; 20 class CPDF_Document; 21 class CPDF_Font; 22 23 class CFGAS_PDFFontMgr : public Observable<CFGAS_PDFFontMgr> { 24 public: 25 explicit CFGAS_PDFFontMgr(CPDF_Document* pDoc, CFGAS_FontMgr* pFontMgr); 26 ~CFGAS_PDFFontMgr(); 27 28 void SetFont(const RetainPtr<CFGAS_GEFont>& pFont, CPDF_Font* pPDFFont); 29 RetainPtr<CFGAS_GEFont> GetFont(const WideStringView& wsFontFamily, 30 uint32_t dwFontStyles, 31 CPDF_Font** pPDFFont, 32 bool bStrictMatch); 33 bool GetCharWidth(const RetainPtr<CFGAS_GEFont>& pFont, 34 wchar_t wUnicode, 35 int32_t* pWidth); 36 37 private: 38 RetainPtr<CFGAS_GEFont> FindFont(const ByteString& strFamilyName, 39 bool bBold, 40 bool bItalic, 41 CPDF_Font** pPDFFont, 42 bool bStrictMatch); 43 ByteString PsNameToFontName(const ByteString& strPsName, 44 bool bBold, 45 bool bItalic); 46 bool PsNameMatchDRFontName(const ByteStringView& bsPsName, 47 bool bBold, 48 bool bItalic, 49 const ByteString& bsDRFontName, 50 bool bStrictMatch); 51 52 UnownedPtr<CPDF_Document> const m_pDoc; 53 UnownedPtr<CFGAS_FontMgr> const m_pFontMgr; 54 std::map<RetainPtr<CFGAS_GEFont>, CPDF_Font*> m_FDE2PDFFont; 55 std::map<ByteString, RetainPtr<CFGAS_GEFont>> m_FontMap; 56 }; 57 58 #endif // XFA_FGAS_FONT_CFGAS_PDFFONTMGR_H_ 59