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 #ifndef CORE_FPDFAPI_FONT_CPDF_TOUNICODEMAP_H_ 8 #define CORE_FPDFAPI_FONT_CPDF_TOUNICODEMAP_H_ 9 10 #include <map> 11 12 #include "core/fpdfapi/parser/cpdf_stream.h" 13 #include "core/fxcrt/cfx_widetextbuf.h" 14 #include "core/fxcrt/unowned_ptr.h" 15 16 class CPDF_CID2UnicodeMap; 17 18 class CPDF_ToUnicodeMap { 19 public: 20 CPDF_ToUnicodeMap(); 21 ~CPDF_ToUnicodeMap(); 22 23 void Load(CPDF_Stream* pStream); 24 25 WideString Lookup(uint32_t charcode) const; 26 uint32_t ReverseLookup(wchar_t unicode) const; 27 28 private: 29 friend class cpdf_tounicodemap_StringToCode_Test; 30 friend class cpdf_tounicodemap_StringToWideString_Test; 31 32 static uint32_t StringToCode(const ByteStringView& str); 33 static WideString StringToWideString(const ByteStringView& str); 34 35 uint32_t GetUnicode(); 36 37 std::map<uint32_t, uint32_t> m_Map; 38 UnownedPtr<CPDF_CID2UnicodeMap> m_pBaseMap; 39 CFX_WideTextBuf m_MultiCharBuf; 40 }; 41 42 #endif // CORE_FPDFAPI_FONT_CPDF_TOUNICODEMAP_H_ 43