• 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 
17 class CPDF_Dictionary;
18 class CPDF_Type3Char;
19 
20 class CPDF_Type3Font : public CPDF_SimpleFont {
21  public:
22   CPDF_Type3Font();
23   ~CPDF_Type3Font() override;
24 
25   // CPDF_Font:
26   bool IsType3Font() const override;
27   const CPDF_Type3Font* AsType3Font() const override;
28   CPDF_Type3Font* AsType3Font() override;
29   int GetCharWidthF(uint32_t charcode) override;
30   FX_RECT GetCharBBox(uint32_t charcode) override;
31 
SetPageResources(CPDF_Dictionary * pResources)32   void SetPageResources(CPDF_Dictionary* pResources) {
33     m_pPageResources = pResources;
34   }
35   CPDF_Type3Char* LoadChar(uint32_t charcode);
36   void CheckType3FontMetrics();
37 
GetFontMatrix()38   CFX_Matrix& GetFontMatrix() { return m_FontMatrix; }
39 
40  protected:
41   CFX_Matrix m_FontMatrix;
42 
43  private:
44   // CPDF_Font:
45   bool Load() override;
46 
47   // CPDF_SimpleFont:
LoadGlyphMap()48   void LoadGlyphMap() override {}
49 
50   int m_CharWidthL[256];
51   CPDF_Dictionary* m_pCharProcs;
52   CPDF_Dictionary* m_pPageResources;
53   CPDF_Dictionary* m_pFontResources;
54   std::map<uint32_t, std::unique_ptr<CPDF_Type3Char>> m_CacheMap;
55   // The depth char loading is in, to avoid recurive calling LoadChar().
56   int m_CharLoadingDepth;
57 };
58 
59 #endif  // CORE_FPDFAPI_FONT_CPDF_TYPE3FONT_H_
60