1 // Copyright 2016 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_CIDFONT_H_ 8 #define CORE_FPDFAPI_FONT_CPDF_CIDFONT_H_ 9 10 #include <memory> 11 #include <vector> 12 13 #include "core/fpdfapi/font/cpdf_font.h" 14 #include "core/fxcrt/cfx_maybe_owned.h" 15 #include "core/fxcrt/fx_string.h" 16 #include "core/fxcrt/fx_system.h" 17 18 enum CIDSet { 19 CIDSET_UNKNOWN, 20 CIDSET_GB1, 21 CIDSET_CNS1, 22 CIDSET_JAPAN1, 23 CIDSET_KOREA1, 24 CIDSET_UNICODE, 25 CIDSET_NUM_SETS 26 }; 27 28 class CFX_CTTGSUBTable; 29 class CPDF_Array; 30 class CPDF_CID2UnicodeMap; 31 class CPDF_CMap; 32 class CPDF_StreamAcc; 33 34 class CPDF_CIDFont : public CPDF_Font { 35 public: 36 CPDF_CIDFont(); 37 ~CPDF_CIDFont() override; 38 39 static FX_FLOAT CIDTransformToFloat(uint8_t ch); 40 41 // CPDF_Font: 42 bool IsCIDFont() const override; 43 const CPDF_CIDFont* AsCIDFont() const override; 44 CPDF_CIDFont* AsCIDFont() override; 45 int GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) override; 46 int GetCharWidthF(uint32_t charcode) override; 47 FX_RECT GetCharBBox(uint32_t charcode) override; 48 uint32_t GetNextChar(const FX_CHAR* pString, 49 int nStrLen, 50 int& offset) const override; 51 int CountChar(const FX_CHAR* pString, int size) const override; 52 int AppendChar(FX_CHAR* str, uint32_t charcode) const override; 53 bool IsVertWriting() const override; 54 bool IsUnicodeCompatible() const override; 55 bool Load() override; 56 CFX_WideString UnicodeFromCharCode(uint32_t charcode) const override; 57 uint32_t CharCodeFromUnicode(FX_WCHAR Unicode) const override; 58 59 uint16_t CIDFromCharCode(uint32_t charcode) const; 60 const uint8_t* GetCIDTransform(uint16_t CID) const; 61 short GetVertWidth(uint16_t CID) const; 62 void GetVertOrigin(uint16_t CID, short& vx, short& vy) const; 63 int GetCharSize(uint32_t charcode) const; 64 65 protected: 66 void LoadGB2312(); 67 int GetGlyphIndex(uint32_t unicodeb, bool* pVertGlyph); 68 int GetVerticalGlyph(int index, bool* pVertGlyph); 69 void LoadMetricsArray(CPDF_Array* pArray, 70 std::vector<uint32_t>* result, 71 int nElements); 72 void LoadSubstFont(); 73 FX_WCHAR GetUnicodeFromCharCode(uint32_t charcode) const; 74 75 CFX_MaybeOwned<CPDF_CMap> m_pCMap; 76 CPDF_CID2UnicodeMap* m_pCID2UnicodeMap; 77 CIDSet m_Charset; 78 bool m_bType1; 79 bool m_bCIDIsGID; 80 uint16_t m_DefaultWidth; 81 std::unique_ptr<CPDF_StreamAcc> m_pStreamAcc; 82 bool m_bAnsiWidthsFixed; 83 FX_RECT m_CharBBox[256]; 84 std::vector<uint32_t> m_WidthList; 85 short m_DefaultVY; 86 short m_DefaultW1; 87 std::vector<uint32_t> m_VertMetrics; 88 bool m_bAdobeCourierStd; 89 std::unique_ptr<CFX_CTTGSUBTable> m_pTTGSUBTable; 90 }; 91 92 #endif // CORE_FPDFAPI_FONT_CPDF_CIDFONT_H_ 93