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_CMAPPARSER_H_ 8 #define CORE_FPDFAPI_FONT_CPDF_CMAPPARSER_H_ 9 10 #include <map> 11 #include <utility> 12 #include <vector> 13 14 #include "core/fpdfapi/font/cpdf_cidfont.h" 15 #include "core/fpdfapi/font/cpdf_cmap.h" 16 #include "core/fxcrt/unowned_ptr.h" 17 18 class CPDF_CMapParser { 19 public: 20 explicit CPDF_CMapParser(CPDF_CMap* pMap); 21 ~CPDF_CMapParser(); 22 23 void ParseWord(const ByteStringView& str); HasAdditionalMappings()24 bool HasAdditionalMappings() const { 25 return !m_AdditionalCharcodeToCIDMappings.empty(); 26 } TakeAdditionalMappings()27 std::vector<CPDF_CMap::CIDRange> TakeAdditionalMappings() { 28 return std::move(m_AdditionalCharcodeToCIDMappings); 29 } 30 31 uint32_t GetCode(const ByteStringView& word) const; 32 bool GetCodeRange(CPDF_CMap::CodeRange& range, 33 const ByteStringView& first, 34 const ByteStringView& second) const; 35 36 static CIDSet CharsetFromOrdering(const ByteStringView& ordering); 37 38 private: 39 40 UnownedPtr<CPDF_CMap> const m_pCMap; 41 int m_Status; 42 int m_CodeSeq; 43 uint32_t m_CodePoints[4]; 44 std::vector<CPDF_CMap::CodeRange> m_CodeRanges; 45 std::vector<CPDF_CMap::CIDRange> m_AdditionalCharcodeToCIDMappings; 46 ByteString m_LastWord; 47 }; 48 49 #endif // CORE_FPDFAPI_FONT_CPDF_CMAPPARSER_H_ 50