From bc5e6d289ed40efec2b0e03427e8fc2947bf53e3 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Tue, 4 Oct 2016 11:08:49 -0700 Subject: Move core/fpdfapi/fpdf_font to core/fpdfapi/font BUG=pdfium:603 Review-Url: https://codereview.chromium.org/2392773003 --- core/fpdfapi/font/cpdf_cidfont.h | 91 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 core/fpdfapi/font/cpdf_cidfont.h (limited to 'core/fpdfapi/font/cpdf_cidfont.h') diff --git a/core/fpdfapi/font/cpdf_cidfont.h b/core/fpdfapi/font/cpdf_cidfont.h new file mode 100644 index 0000000000..0a6b3e7871 --- /dev/null +++ b/core/fpdfapi/font/cpdf_cidfont.h @@ -0,0 +1,91 @@ +// Copyright 2016 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_FPDFAPI_FONT_CPDF_CIDFONT_H_ +#define CORE_FPDFAPI_FONT_CPDF_CIDFONT_H_ + +#include + +#include "core/fpdfapi/font/cpdf_font.h" +#include "core/fxcrt/fx_string.h" +#include "core/fxcrt/fx_system.h" + +enum CIDSet { + CIDSET_UNKNOWN, + CIDSET_GB1, + CIDSET_CNS1, + CIDSET_JAPAN1, + CIDSET_KOREA1, + CIDSET_UNICODE, + CIDSET_NUM_SETS +}; + +class CFX_CTTGSUBTable; +class CPDF_Array; +class CPDF_CID2UnicodeMap; +class CPDF_CMap; +class CPDF_StreamAcc; + +class CPDF_CIDFont : public CPDF_Font { + public: + CPDF_CIDFont(); + ~CPDF_CIDFont() override; + + static FX_FLOAT CIDTransformToFloat(uint8_t ch); + + // CPDF_Font: + bool IsCIDFont() const override; + const CPDF_CIDFont* AsCIDFont() const override; + CPDF_CIDFont* AsCIDFont() override; + int GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) override; + int GetCharWidthF(uint32_t charcode) override; + FX_RECT GetCharBBox(uint32_t charcode) override; + uint32_t GetNextChar(const FX_CHAR* pString, + int nStrLen, + int& offset) const override; + int CountChar(const FX_CHAR* pString, int size) const override; + int AppendChar(FX_CHAR* str, uint32_t charcode) const override; + int GetCharSize(uint32_t charcode) const override; + bool IsVertWriting() const override; + bool IsUnicodeCompatible() const override; + bool Load() override; + CFX_WideString UnicodeFromCharCode(uint32_t charcode) const override; + uint32_t CharCodeFromUnicode(FX_WCHAR Unicode) const override; + + uint16_t CIDFromCharCode(uint32_t charcode) const; + const uint8_t* GetCIDTransform(uint16_t CID) const; + short GetVertWidth(uint16_t CID) const; + void GetVertOrigin(uint16_t CID, short& vx, short& vy) const; + + protected: + void LoadGB2312(); + int GetGlyphIndex(uint32_t unicodeb, bool* pVertGlyph); + int GetVerticalGlyph(int index, bool* pVertGlyph); + void LoadMetricsArray(CPDF_Array* pArray, + CFX_ArrayTemplate& result, + int nElements); + void LoadSubstFont(); + FX_WCHAR GetUnicodeFromCharCode(uint32_t charcode) const; + + CPDF_CMap* m_pCMap; + std::unique_ptr m_pAllocatedCMap; + CPDF_CID2UnicodeMap* m_pCID2UnicodeMap; + CIDSet m_Charset; + bool m_bType1; + bool m_bCIDIsGID; + uint16_t m_DefaultWidth; + std::unique_ptr m_pStreamAcc; + bool m_bAnsiWidthsFixed; + FX_RECT m_CharBBox[256]; + CFX_ArrayTemplate m_WidthList; + short m_DefaultVY; + short m_DefaultW1; + CFX_ArrayTemplate m_VertMetrics; + bool m_bAdobeCourierStd; + std::unique_ptr m_pTTGSUBTable; +}; + +#endif // CORE_FPDFAPI_FONT_CPDF_CIDFONT_H_ -- cgit v1.2.3