OLD | NEW |
(Empty) | |
| 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_FPDF_PAGE_INCLUDE_CPDF_TEXTOBJECT_H_ |
| 8 #define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_TEXTOBJECT_H_ |
| 9 |
| 10 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" |
| 11 #include "core/include/fxcrt/fx_string.h" |
| 12 #include "core/include/fxcrt/fx_system.h" |
| 13 |
| 14 struct CPDF_TextObjectItem { |
| 15 FX_DWORD m_CharCode; |
| 16 FX_FLOAT m_OriginX; |
| 17 FX_FLOAT m_OriginY; |
| 18 }; |
| 19 |
| 20 class CPDF_TextObject : public CPDF_PageObject { |
| 21 public: |
| 22 CPDF_TextObject(); |
| 23 ~CPDF_TextObject() override; |
| 24 |
| 25 // CPDF_PageObject: |
| 26 CPDF_TextObject* Clone() const override; |
| 27 Type GetType() const override { return TEXT; }; |
| 28 void Transform(const CFX_Matrix& matrix) override; |
| 29 bool IsText() const override { return true; }; |
| 30 CPDF_TextObject* AsText() override { return this; }; |
| 31 const CPDF_TextObject* AsText() const override { return this; }; |
| 32 |
| 33 int CountItems() const { return m_nChars; } |
| 34 void GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const; |
| 35 int CountChars() const; |
| 36 void GetCharInfo(int index, FX_DWORD& charcode, FX_FLOAT& kerning) const; |
| 37 void GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const; |
| 38 FX_FLOAT GetCharWidth(FX_DWORD charcode) const; |
| 39 FX_FLOAT GetPosX() const { return m_PosX; } |
| 40 FX_FLOAT GetPosY() const { return m_PosY; } |
| 41 void GetTextMatrix(CFX_Matrix* pMatrix) const; |
| 42 CPDF_Font* GetFont() const { return m_TextState.GetFont(); } |
| 43 FX_FLOAT GetFontSize() const { return m_TextState.GetFontSize(); } |
| 44 |
| 45 void SetText(const CFX_ByteString& text); |
| 46 void SetPosition(FX_FLOAT x, FX_FLOAT y); |
| 47 |
| 48 void RecalcPositionData() { CalcPositionData(nullptr, nullptr, 1); } |
| 49 |
| 50 protected: |
| 51 friend class CPDF_RenderStatus; |
| 52 friend class CPDF_StreamContentParser; |
| 53 friend class CPDF_TextRenderer; |
| 54 |
| 55 void SetSegments(const CFX_ByteString* pStrs, FX_FLOAT* pKerning, int nSegs); |
| 56 |
| 57 void CalcPositionData(FX_FLOAT* pTextAdvanceX, |
| 58 FX_FLOAT* pTextAdvanceY, |
| 59 FX_FLOAT horz_scale, |
| 60 int level = 0); |
| 61 |
| 62 FX_FLOAT m_PosX; |
| 63 FX_FLOAT m_PosY; |
| 64 int m_nChars; |
| 65 FX_DWORD* m_pCharCodes; |
| 66 FX_FLOAT* m_pCharPos; |
| 67 }; |
| 68 |
| 69 #endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_TEXTOBJECT_H_ |
OLD | NEW |