• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FPDFAPI_FONT_CPDF_TYPE3FONT_H_
8 #define CORE_FPDFAPI_FONT_CPDF_TYPE3FONT_H_
9 
10 #include <stdint.h>
11 
12 #include <array>
13 #include <map>
14 #include <memory>
15 
16 #include "core/fpdfapi/font/cpdf_simplefont.h"
17 #include "core/fxcrt/fx_coordinates.h"
18 #include "core/fxcrt/retain_ptr.h"
19 #include "core/fxcrt/unowned_ptr.h"
20 
21 class CPDF_Dictionary;
22 class CPDF_Document;
23 class CPDF_Type3Char;
24 
25 class CPDF_Type3Font final : public CPDF_SimpleFont {
26  public:
27   CONSTRUCT_VIA_MAKE_RETAIN;
28   ~CPDF_Type3Font() override;
29 
30   // CPDF_Font:
31   bool IsType3Font() const override;
32   const CPDF_Type3Font* AsType3Font() const override;
33   CPDF_Type3Font* AsType3Font() override;
34   void WillBeDestroyed() override;
35   int GetCharWidthF(uint32_t charcode) override;
36   FX_RECT GetCharBBox(uint32_t charcode) override;
37 
SetPageResources(CPDF_Dictionary * pResources)38   void SetPageResources(CPDF_Dictionary* pResources) {
39     m_pPageResources.Reset(pResources);
40   }
41   CPDF_Type3Char* LoadChar(uint32_t charcode);
42   void CheckType3FontMetrics();
43 
GetFontMatrix()44   CFX_Matrix& GetFontMatrix() { return m_FontMatrix; }
45 
46  private:
47   CPDF_Type3Font(CPDF_Document* pDocument,
48                  RetainPtr<CPDF_Dictionary> pFontDict,
49                  FormFactoryIface* pFormFactory);
50 
51   // CPDF_Font:
52   bool Load() override;
53 
54   // CPDF_SimpleFont:
55   void LoadGlyphMap() override;
56 
57   // The depth char loading is in, to avoid recurive calling LoadChar().
58   int m_CharLoadingDepth = 0;
59   CFX_Matrix m_FontMatrix;
60   UnownedPtr<FormFactoryIface> const m_pFormFactory;
61   RetainPtr<CPDF_Dictionary> m_pCharProcs;
62   RetainPtr<CPDF_Dictionary> m_pPageResources;
63   RetainPtr<CPDF_Dictionary> m_pFontResources;
64   std::map<uint32_t, std::unique_ptr<CPDF_Type3Char>> m_CacheMap;
65   std::array<int, 256> m_CharWidthL = {};
66 };
67 
68 #endif  // CORE_FPDFAPI_FONT_CPDF_TYPE3FONT_H_
69