xref: /aosp_15_r20/external/pdfium/core/fxge/cfx_gemodule.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
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 #include "core/fxcrt/unowned_ptr_exclusion.h"
16 
17 #if BUILDFLAG(IS_APPLE)
18 #include "third_party/base/containers/span.h"
19 #endif
20 
21 class CFX_FontCache;
22 class CFX_FontMgr;
23 class SystemFontInfoIface;
24 
25 class CFX_GEModule {
26  public:
27   class PlatformIface {
28    public:
29     static std::unique_ptr<PlatformIface> Create();
30     virtual ~PlatformIface() = default;
31 
32     virtual void Init() = 0;
33     virtual std::unique_ptr<SystemFontInfoIface>
34     CreateDefaultSystemFontInfo() = 0;
35 #if BUILDFLAG(IS_APPLE)
36     virtual void* CreatePlatformFont(pdfium::span<const uint8_t> font_span) = 0;
37 #endif
38   };
39 
40   static void Create(const char** pUserFontPaths);
41   static void Destroy();
42   static CFX_GEModule* Get();
43 
GetFontCache()44   CFX_FontCache* GetFontCache() const { return m_pFontCache.get(); }
GetFontMgr()45   CFX_FontMgr* GetFontMgr() const { return m_pFontMgr.get(); }
GetPlatform()46   PlatformIface* GetPlatform() const { return m_pPlatform.get(); }
GetUserFontPaths()47   const char** GetUserFontPaths() const { return m_pUserFontPaths; }
48 
49  private:
50   explicit CFX_GEModule(const char** pUserFontPaths);
51   ~CFX_GEModule();
52 
53   std::unique_ptr<PlatformIface> const m_pPlatform;
54   std::unique_ptr<CFX_FontMgr> const m_pFontMgr;
55   std::unique_ptr<CFX_FontCache> const m_pFontCache;
56 
57   // Exclude because taken from public API.
58   UNOWNED_PTR_EXCLUSION const char** const m_pUserFontPaths;
59 };
60 
61 #endif  // CORE_FXGE_CFX_GEMODULE_H_
62