blob: a01474408f30658cfd1eee8658a487c7af7fa168 [file] [log] [blame]
kumarashishg826308d2023-06-23 13:21:22 +00001// Copyright 2017 The PDFium Authors
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -07002// 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>
kumarashishg826308d2023-06-23 13:21:22 +000011#include <utility>
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070012
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070013#include "core/fxcrt/fx_string.h"
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070014#include "core/fxcrt/retain_ptr.h"
kumarashishg826308d2023-06-23 13:21:22 +000015#include "core/fxcrt/unowned_ptr.h"
16#include "xfa/fgas/font/cfgas_fontmgr.h"
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070017
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070018class CFGAS_GEFont;
19class CPDF_Document;
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070020
kumarashishg826308d2023-06-23 13:21:22 +000021class CFGAS_PDFFontMgr final {
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070022 public:
kumarashishg826308d2023-06-23 13:21:22 +000023 explicit CFGAS_PDFFontMgr(const CPDF_Document* pDoc);
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070024 ~CFGAS_PDFFontMgr();
25
kumarashishg826308d2023-06-23 13:21:22 +000026 RetainPtr<CFGAS_GEFont> GetFont(const WideString& wsFontFamily,
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070027 uint32_t dwFontStyles,
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070028 bool bStrictMatch);
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070029
30 private:
31 RetainPtr<CFGAS_GEFont> FindFont(const ByteString& strFamilyName,
32 bool bBold,
33 bool bItalic,
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070034 bool bStrictMatch);
35 ByteString PsNameToFontName(const ByteString& strPsName,
36 bool bBold,
37 bool bItalic);
Haibo Huang49cc9302020-04-27 16:14:24 -070038 bool PsNameMatchDRFontName(ByteStringView bsPsName,
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070039 bool bBold,
40 bool bItalic,
41 const ByteString& bsDRFontName,
42 bool bStrictMatch);
43
kumarashishg826308d2023-06-23 13:21:22 +000044 UnownedPtr<const CPDF_Document> const m_pDoc;
45 std::map<std::pair<WideString, uint32_t>, RetainPtr<CFGAS_GEFont>> m_FontMap;
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070046};
47
48#endif // XFA_FGAS_FONT_CFGAS_PDFFONTMGR_H_