• 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 #include "core/fxge/cfx_gemodule.h"
8 
9 #include "core/fxge/cfx_folderfontinfo.h"
10 #include "core/fxge/cfx_fontcache.h"
11 #include "core/fxge/cfx_fontmgr.h"
12 #include "third_party/base/ptr_util.h"
13 
14 namespace {
15 
16 CFX_GEModule* g_pGEModule = nullptr;
17 
18 }  // namespace
19 
CFX_GEModule()20 CFX_GEModule::CFX_GEModule()
21     : m_pFontMgr(pdfium::MakeUnique<CFX_FontMgr>()),
22       m_pPlatformData(nullptr),
23       m_pUserFontPaths(nullptr) {}
24 
~CFX_GEModule()25 CFX_GEModule::~CFX_GEModule() {
26   DestroyPlatform();
27 }
28 
29 // static
Get()30 CFX_GEModule* CFX_GEModule::Get() {
31   if (!g_pGEModule)
32     g_pGEModule = new CFX_GEModule();
33   return g_pGEModule;
34 }
35 
36 // static
Destroy()37 void CFX_GEModule::Destroy() {
38   ASSERT(g_pGEModule);
39   delete g_pGEModule;
40   g_pGEModule = nullptr;
41 }
42 
Init(const char ** userFontPaths)43 void CFX_GEModule::Init(const char** userFontPaths) {
44   ASSERT(g_pGEModule);
45   m_pUserFontPaths = userFontPaths;
46   InitPlatform();
47 }
48 
GetFontCache()49 CFX_FontCache* CFX_GEModule::GetFontCache() {
50   if (!m_pFontCache)
51     m_pFontCache = pdfium::MakeUnique<CFX_FontCache>();
52   return m_pFontCache.get();
53 }
54