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 CONSTRUCT_VIA_MAKE_RETAIN; 26 ~CPDF_Type3Font() override; 27 28 // CPDF_Font: 29 bool IsType3Font() const override; 30 const CPDF_Type3Font* AsType3Font() const override; 31 CPDF_Type3Font* AsType3Font() override; 32 void WillBeDestroyed() override; 33 int GetCharWidthF(uint32_t charcode) override; 34 FX_RECT GetCharBBox(uint32_t charcode) override; 35 SetPageResources(CPDF_Dictionary * pResources)36 void SetPageResources(CPDF_Dictionary* pResources) { 37 m_pPageResources.Reset(pResources); 38 } 39 CPDF_Type3Char* LoadChar(uint32_t charcode); 40 void CheckType3FontMetrics(); 41 GetFontMatrix()42 CFX_Matrix& GetFontMatrix() { return m_FontMatrix; } 43 44 private: 45 CPDF_Type3Font(CPDF_Document* pDocument, 46 CPDF_Dictionary* pFontDict, 47 FormFactoryIface* pFormFactory); 48 49 // CPDF_Font: 50 bool Load() override; 51 52 // CPDF_SimpleFont: 53 void LoadGlyphMap() override; 54 55 // The depth char loading is in, to avoid recurive calling LoadChar(). 56 int m_CharLoadingDepth = 0; 57 CFX_Matrix m_FontMatrix; 58 UnownedPtr<FormFactoryIface> const m_pFormFactory; 59 RetainPtr<CPDF_Dictionary> m_pCharProcs; 60 RetainPtr<CPDF_Dictionary> m_pPageResources; 61 RetainPtr<CPDF_Dictionary> m_pFontResources; 62 std::map<uint32_t, std::unique_ptr<CPDF_Type3Char>> m_CacheMap; 63 int m_CharWidthL[256] = {}; 64 }; 65 66 #endif // CORE_FPDFAPI_FONT_CPDF_TYPE3FONT_H_ 67