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/font/cpdf_fontglobals.h" 10 CPDF_CID2UnicodeMap(CIDSet charset)11CPDF_CID2UnicodeMap::CPDF_CID2UnicodeMap(CIDSet charset) 12 : m_Charset(charset), 13 m_pEmbeddedMap( 14 CPDF_FontGlobals::GetInstance()->GetEmbeddedToUnicode(m_Charset)) {} 15 16 CPDF_CID2UnicodeMap::~CPDF_CID2UnicodeMap() = default; 17 IsLoaded() const18bool CPDF_CID2UnicodeMap::IsLoaded() const { 19 return !m_pEmbeddedMap.empty(); 20 } 21 UnicodeFromCID(uint16_t cid) const22wchar_t CPDF_CID2UnicodeMap::UnicodeFromCID(uint16_t cid) const { 23 if (m_Charset == CIDSET_UNICODE) 24 return cid; 25 return cid < m_pEmbeddedMap.size() ? m_pEmbeddedMap[cid] : 0; 26 } 27