// Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #ifndef CORE_FPDFDOC_CBA_FONTMAP_H_ #define CORE_FPDFDOC_CBA_FONTMAP_H_ #include #include #include "core/fpdfdoc/ipvt_fontmap.h" #include "core/fxcrt/fx_codepage.h" #include "core/fxcrt/retain_ptr.h" #include "core/fxcrt/unowned_ptr.h" class CPDF_Dictionary; class CPDF_Document; class CBA_FontMap final : public IPVT_FontMap { public: static int32_t GetNativeCharset(); CBA_FontMap(CPDF_Document* pDocument, CPDF_Dictionary* pAnnotDict); ~CBA_FontMap() override; // IPVT_FontMap RetainPtr GetPDFFont(int32_t nFontIndex) override; ByteString GetPDFFontAlias(int32_t nFontIndex) override; int32_t GetWordFontIndex(uint16_t word, int32_t nCharset, int32_t nFontIndex) override; int32_t CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) override; int32_t CharSetFromUnicode(uint16_t word, int32_t nOldCharset) override; void Reset(); void SetAPType(const ByteString& sAPType); private: struct Data { Data(); ~Data(); RetainPtr pFont; int32_t nCharset; ByteString sFontName; }; struct Native { int32_t nCharset; ByteString sFontName; }; void Initialize(); RetainPtr FindFontSameCharset(ByteString* sFontAlias, int32_t nCharset); RetainPtr FindResFontSameCharset(const CPDF_Dictionary* pResDict, ByteString* sFontAlias, int32_t nCharset); RetainPtr GetAnnotDefaultFont(ByteString* sAlias); void AddFontToAnnotDict(const RetainPtr& pFont, const ByteString& sAlias); bool KnowWord(int32_t nFontIndex, uint16_t word); void Clear(); int32_t GetFontIndex(const ByteString& sFontName, int32_t nCharset, bool bFind); int32_t AddFontData(const RetainPtr& pFont, const ByteString& sFontAlias, int32_t nCharset); ByteString EncodeFontAlias(const ByteString& sFontName, int32_t nCharset); ByteString EncodeFontAlias(const ByteString& sFontName); int32_t FindFont(const ByteString& sFontName, int32_t nCharset); ByteString GetNativeFontName(int32_t nCharset); ByteString GetCachedNativeFontName(int32_t nCharset); bool IsStandardFont(const ByteString& sFontName); RetainPtr AddFontToDocument(ByteString sFontName, uint8_t nCharset); RetainPtr AddStandardFont(ByteString sFontName); RetainPtr AddSystemFont(ByteString sFontName, uint8_t nCharset); std::vector> m_Data; std::vector> m_NativeFont; UnownedPtr const m_pDocument; RetainPtr const m_pAnnotDict; RetainPtr m_pDefaultFont; ByteString m_sDefaultFontName; ByteString m_sAPType = "N"; }; #endif // CORE_FPDFDOC_CBA_FONTMAP_H_