1 // Copyright 2014 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 "../../../include/fxge/fx_ge.h" 8 #include "text_int.h" 9 static CFX_GEModule* g_pGEModule = NULL; CFX_GEModule()10CFX_GEModule::CFX_GEModule() 11 { 12 m_pFontCache = NULL; 13 m_pFontMgr = NULL; 14 m_FTLibrary = NULL; 15 m_pCodecModule = NULL; 16 m_pPlatformData = NULL; 17 } ~CFX_GEModule()18CFX_GEModule::~CFX_GEModule() 19 { 20 if (m_pFontCache) { 21 delete m_pFontCache; 22 } 23 m_pFontCache = NULL; 24 if (m_pFontMgr) { 25 delete m_pFontMgr; 26 } 27 m_pFontMgr = NULL; 28 DestroyPlatform(); 29 } Get()30CFX_GEModule* CFX_GEModule::Get() 31 { 32 return g_pGEModule; 33 } Create()34void CFX_GEModule::Create() 35 { 36 g_pGEModule = FX_NEW CFX_GEModule; 37 if (!g_pGEModule) { 38 return; 39 } 40 g_pGEModule->m_pFontMgr = FX_NEW CFX_FontMgr; 41 g_pGEModule->InitPlatform(); 42 g_pGEModule->SetTextGamma(2.2f); 43 } Use(CFX_GEModule * pModule)44void CFX_GEModule::Use(CFX_GEModule* pModule) 45 { 46 g_pGEModule = pModule; 47 } Destroy()48void CFX_GEModule::Destroy() 49 { 50 if (g_pGEModule) { 51 delete g_pGEModule; 52 } 53 g_pGEModule = NULL; 54 } GetFontCache()55CFX_FontCache* CFX_GEModule::GetFontCache() 56 { 57 if (m_pFontCache == NULL) { 58 m_pFontCache = FX_NEW CFX_FontCache(); 59 } 60 return m_pFontCache; 61 } SetTextGamma(FX_FLOAT gammaValue)62void CFX_GEModule::SetTextGamma(FX_FLOAT gammaValue) 63 { 64 gammaValue /= 2.2f; 65 int i = 0; 66 while (i < 256) { 67 m_GammaValue[i] = (FX_BYTE)(FXSYS_pow((FX_FLOAT)i / 255, gammaValue) * 255.0f + 0.5f); 68 i++; 69 } 70 } GetTextGammaTable()71FX_LPCBYTE CFX_GEModule::GetTextGammaTable() 72 { 73 return m_GammaValue; 74 } SetExtFontMapper(IFX_FontMapper * pFontMapper)75void CFX_GEModule::SetExtFontMapper(IFX_FontMapper* pFontMapper) 76 { 77 GetFontMgr()->m_pExtMapper = pFontMapper; 78 pFontMapper->m_pFontMgr = m_pFontMgr; 79 } 80