1 // Copyright 2017 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/fpdfapi/font/cpdf_cid2unicodemap.h" 8 9 #include "core/fpdfapi/cpdf_modulemgr.h" 10 #include "core/fpdfapi/font/cpdf_cmapmanager.h" 11 #include "core/fpdfapi/page/cpdf_pagemodule.h" 12 CPDF_CID2UnicodeMap()13CPDF_CID2UnicodeMap::CPDF_CID2UnicodeMap() { 14 m_EmbeddedCount = 0; 15 } 16 ~CPDF_CID2UnicodeMap()17CPDF_CID2UnicodeMap::~CPDF_CID2UnicodeMap() {} 18 IsLoaded()19bool CPDF_CID2UnicodeMap::IsLoaded() { 20 return m_EmbeddedCount != 0; 21 } 22 UnicodeFromCID(uint16_t CID)23wchar_t CPDF_CID2UnicodeMap::UnicodeFromCID(uint16_t CID) { 24 if (m_Charset == CIDSET_UNICODE) { 25 return CID; 26 } 27 if (CID < m_EmbeddedCount) { 28 return m_pEmbeddedMap[CID]; 29 } 30 return 0; 31 } 32 Load(CPDF_CMapManager * pMgr,CIDSet charset,bool bPromptCJK)33void CPDF_CID2UnicodeMap::Load(CPDF_CMapManager* pMgr, 34 CIDSet charset, 35 bool bPromptCJK) { 36 m_Charset = charset; 37 38 CPDF_FontGlobals* pFontGlobals = 39 CPDF_ModuleMgr::Get()->GetPageModule()->GetFontGlobals(); 40 std::tie(m_EmbeddedCount, m_pEmbeddedMap) = 41 pFontGlobals->GetEmbeddedToUnicode(charset); 42 } 43