• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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 CORE_FPDFAPI_FONT_CPDF_TYPE3FONT_H_
8 #define CORE_FPDFAPI_FONT_CPDF_TYPE3FONT_H_
9 
10 #include <map>
11 #include <memory>
12 
13 #include "core/fpdfapi/font/cpdf_simplefont.h"
14 #include "core/fxcrt/fx_coordinates.h"
15 #include "core/fxcrt/fx_system.h"
16 #include "core/fxcrt/unowned_ptr.h"
17 
18 class CPDF_Dictionary;
19 class CPDF_Document;
20 class CPDF_Stream;
21 class CPDF_Type3Char;
22 
23 class CPDF_Type3Font final : public CPDF_SimpleFont {
24  public:
25   template <typename T, typename... Args>
26   friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
27 
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   uint32_t 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                  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   uint32_t m_CharWidthL[256];
66 };
67 
68 #endif  // CORE_FPDFAPI_FONT_CPDF_TYPE3FONT_H_
69