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_FXGE_CFX_GEMODULE_H_ 8 #define CORE_FXGE_CFX_GEMODULE_H_ 9 10 #include <stdint.h> 11 12 #include <memory> 13 14 #include "build/build_config.h" 15 16 #if BUILDFLAG(IS_APPLE) 17 #include "third_party/base/span.h" 18 #endif 19 20 class CFX_FontCache; 21 class CFX_FontMgr; 22 class SystemFontInfoIface; 23 24 class CFX_GEModule { 25 public: 26 class PlatformIface { 27 public: 28 static std::unique_ptr<PlatformIface> Create(); 29 virtual ~PlatformIface() = default; 30 31 virtual void Init() = 0; 32 virtual std::unique_ptr<SystemFontInfoIface> 33 CreateDefaultSystemFontInfo() = 0; 34 #if BUILDFLAG(IS_APPLE) 35 virtual void* CreatePlatformFont(pdfium::span<const uint8_t> font_span) = 0; 36 #endif 37 }; 38 39 static void Create(const char** pUserFontPaths); 40 static void Destroy(); 41 static CFX_GEModule* Get(); 42 GetFontCache()43 CFX_FontCache* GetFontCache() const { return m_pFontCache.get(); } GetFontMgr()44 CFX_FontMgr* GetFontMgr() const { return m_pFontMgr.get(); } GetPlatform()45 PlatformIface* GetPlatform() const { return m_pPlatform.get(); } GetUserFontPaths()46 const char** GetUserFontPaths() const { return m_pUserFontPaths; } 47 48 private: 49 explicit CFX_GEModule(const char** pUserFontPaths); 50 ~CFX_GEModule(); 51 52 std::unique_ptr<PlatformIface> const m_pPlatform; 53 std::unique_ptr<CFX_FontMgr> const m_pFontMgr; 54 std::unique_ptr<CFX_FontCache> const m_pFontCache; 55 const char** const m_pUserFontPaths; 56 }; 57 58 #endif // CORE_FXGE_CFX_GEMODULE_H_ 59