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/fxcrt/fx_string.h" 13 #include "core/fxcrt/observed_ptr.h" 14 #include "core/fxcrt/retain_ptr.h" 15 16 class CFGAS_FontMgr; 17 class CFGAS_GEFont; 18 class CPDF_Document; 19 20 class CFGAS_PDFFontMgr final : public Observable { 21 public: 22 explicit CFGAS_PDFFontMgr(CPDF_Document* pDoc, CFGAS_FontMgr* pFontMgr); 23 ~CFGAS_PDFFontMgr(); 24 25 RetainPtr<CFGAS_GEFont> GetFont(WideStringView wsFontFamily, 26 uint32_t dwFontStyles, 27 bool bStrictMatch); 28 29 private: 30 RetainPtr<CFGAS_GEFont> FindFont(const ByteString& strFamilyName, 31 bool bBold, 32 bool bItalic, 33 bool bStrictMatch); 34 ByteString PsNameToFontName(const ByteString& strPsName, 35 bool bBold, 36 bool bItalic); 37 bool PsNameMatchDRFontName(ByteStringView bsPsName, 38 bool bBold, 39 bool bItalic, 40 const ByteString& bsDRFontName, 41 bool bStrictMatch); 42 43 UnownedPtr<CPDF_Document> const m_pDoc; 44 UnownedPtr<CFGAS_FontMgr> const m_pFontMgr; 45 std::map<ByteString, RetainPtr<CFGAS_GEFont>> m_FontMap; 46 }; 47 48 #endif // XFA_FGAS_FONT_CFGAS_PDFFONTMGR_H_ 49