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 #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/check.h" 13 14 namespace { 15 16 CFX_GEModule* g_pGEModule = nullptr; 17 18 } // namespace 19 CFX_GEModule(const char ** pUserFontPaths)20CFX_GEModule::CFX_GEModule(const char** pUserFontPaths) 21 : m_pPlatform(PlatformIface::Create()), 22 m_pFontMgr(std::make_unique<CFX_FontMgr>()), 23 m_pFontCache(std::make_unique<CFX_FontCache>()), 24 m_pUserFontPaths(pUserFontPaths) {} 25 26 CFX_GEModule::~CFX_GEModule() = default; 27 28 // static Create(const char ** pUserFontPaths)29void CFX_GEModule::Create(const char** pUserFontPaths) { 30 DCHECK(!g_pGEModule); 31 g_pGEModule = new CFX_GEModule(pUserFontPaths); 32 g_pGEModule->m_pPlatform->Init(); 33 g_pGEModule->GetFontMgr()->GetBuiltinMapper()->SetSystemFontInfo( 34 g_pGEModule->m_pPlatform->CreateDefaultSystemFontInfo()); 35 } 36 37 // static Destroy()38void CFX_GEModule::Destroy() { 39 DCHECK(g_pGEModule); 40 delete g_pGEModule; 41 g_pGEModule = nullptr; 42 } 43 44 // static Get()45CFX_GEModule* CFX_GEModule::Get() { 46 DCHECK(g_pGEModule); 47 return g_pGEModule; 48 } 49