xref: /aosp_15_r20/external/pdfium/core/fpdfdoc/cpvt_fontmap.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2016 The PDFium Authors
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 CORE_FPDFDOC_CPVT_FONTMAP_H_
8 #define CORE_FPDFDOC_CPVT_FONTMAP_H_
9 
10 #include <stdint.h>
11 
12 #include "core/fpdfdoc/ipvt_fontmap.h"
13 #include "core/fxcrt/bytestring.h"
14 #include "core/fxcrt/retain_ptr.h"
15 #include "core/fxcrt/unowned_ptr.h"
16 
17 class CPDF_Document;
18 class CPDF_Dictionary;
19 class CPDF_Font;
20 
21 class CPVT_FontMap final : public IPVT_FontMap {
22  public:
23   CPVT_FontMap(CPDF_Document* pDoc,
24                RetainPtr<CPDF_Dictionary> pResDict,
25                RetainPtr<CPDF_Font> pDefFont,
26                const ByteString& sDefFontAlias);
27   ~CPVT_FontMap() override;
28 
29   // IPVT_FontMap:
30   RetainPtr<CPDF_Font> GetPDFFont(int32_t nFontIndex) override;
31   ByteString GetPDFFontAlias(int32_t nFontIndex) override;
32   int32_t GetWordFontIndex(uint16_t word,
33                            FX_Charset charset,
34                            int32_t nFontIndex) override;
35   int32_t CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) override;
36   FX_Charset CharSetFromUnicode(uint16_t word, FX_Charset nOldCharset) override;
37 
38  private:
39   void SetupAnnotSysPDFFont();
40 
41   UnownedPtr<CPDF_Document> const m_pDocument;
42   RetainPtr<CPDF_Dictionary> const m_pResDict;
43   RetainPtr<CPDF_Font> const m_pDefFont;
44   RetainPtr<CPDF_Font> m_pSysFont;
45   const ByteString m_sDefFontAlias;
46   ByteString m_sSysFontAlias;
47 };
48 
49 #endif  // CORE_FPDFDOC_CPVT_FONTMAP_H_
50