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 | |
Dan Sinclair | db0312e | 2017-09-21 09:46:03 -0400 | [diff] [blame] | 7 | #ifndef XFA_FGAS_FONT_CFGAS_PDFFONTMGR_H_ |
| 8 | #define XFA_FGAS_FONT_CFGAS_PDFFONTMGR_H_ |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 9 | |
| 10 | #include <map> |
| 11 | |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 12 | #include "core/fpdfapi/parser/cpdf_document.h" |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 13 | #include "core/fxcrt/fx_string.h" |
Dan Sinclair | 65ecca4 | 2017-09-21 15:25:32 -0400 | [diff] [blame] | 14 | #include "core/fxcrt/observable.h" |
Dan Sinclair | 0b95042 | 2017-09-21 15:49:49 -0400 | [diff] [blame] | 15 | #include "core/fxcrt/retain_ptr.h" |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 16 | |
Dan Sinclair | db0312e | 2017-09-21 09:46:03 -0400 | [diff] [blame] | 17 | class CFGAS_FontMgr; |
Tom Sepez | d15ce4c | 2017-05-19 17:08:52 -0700 | [diff] [blame] | 18 | class CFGAS_GEFont; |
Dan Sinclair | db0312e | 2017-09-21 09:46:03 -0400 | [diff] [blame] | 19 | class CPDF_Document; |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 20 | |
Tom Sepez | 5586545 | 2018-08-27 20:18:04 +0000 | [diff] [blame] | 21 | class CFGAS_PDFFontMgr final : public Observable<CFGAS_PDFFontMgr> { |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 22 | public: |
Dan Sinclair | db0312e | 2017-09-21 09:46:03 -0400 | [diff] [blame] | 23 | explicit CFGAS_PDFFontMgr(CPDF_Document* pDoc, CFGAS_FontMgr* pFontMgr); |
| 24 | ~CFGAS_PDFFontMgr(); |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 25 | |
Dan Sinclair | 0b95042 | 2017-09-21 15:49:49 -0400 | [diff] [blame] | 26 | RetainPtr<CFGAS_GEFont> GetFont(const WideStringView& wsFontFamily, |
| 27 | uint32_t dwFontStyles, |
Dan Sinclair | 0b95042 | 2017-09-21 15:49:49 -0400 | [diff] [blame] | 28 | bool bStrictMatch); |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 29 | |
| 30 | private: |
Dan Sinclair | 0b95042 | 2017-09-21 15:49:49 -0400 | [diff] [blame] | 31 | RetainPtr<CFGAS_GEFont> FindFont(const ByteString& strFamilyName, |
| 32 | bool bBold, |
| 33 | bool bItalic, |
Dan Sinclair | 0b95042 | 2017-09-21 15:49:49 -0400 | [diff] [blame] | 34 | bool bStrictMatch); |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 35 | ByteString PsNameToFontName(const ByteString& strPsName, |
| 36 | bool bBold, |
| 37 | bool bItalic); |
| 38 | bool PsNameMatchDRFontName(const ByteStringView& bsPsName, |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 39 | bool bBold, |
| 40 | bool bItalic, |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 41 | const ByteString& bsDRFontName, |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 42 | bool bStrictMatch); |
| 43 | |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame] | 44 | UnownedPtr<CPDF_Document> const m_pDoc; |
| 45 | UnownedPtr<CFGAS_FontMgr> const m_pFontMgr; |
Dan Sinclair | 0b95042 | 2017-09-21 15:49:49 -0400 | [diff] [blame] | 46 | std::map<ByteString, RetainPtr<CFGAS_GEFont>> m_FontMap; |
Dan Sinclair | 80c4878 | 2017-03-23 12:11:20 -0400 | [diff] [blame] | 47 | }; |
| 48 | |
Dan Sinclair | db0312e | 2017-09-21 09:46:03 -0400 | [diff] [blame] | 49 | #endif // XFA_FGAS_FONT_CFGAS_PDFFONTMGR_H_ |