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_CPDF_TEXTOBJECT_H_ | |
8 #define CORE_FPDFAPI_FPDF_PAGE_CPDF_TEXTOBJECT_H_ | |
9 | |
10 #include "core/fpdfapi/fpdf_page/cpdf_pageobject.h" | |
11 #include "core/fxcrt/fx_string.h" | |
12 #include "core/fxcrt/fx_system.h" | |
13 | |
14 struct CPDF_TextObjectItem { | |
15 uint32_t 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; | |
28 void Transform(const CFX_Matrix& matrix) override; | |
29 bool IsText() const override; | |
30 CPDF_TextObject* AsText() override; | |
31 const CPDF_TextObject* AsText() const override; | |
32 | |
33 int CountItems() const; | |
34 void GetItemInfo(int index, CPDF_TextObjectItem* pInfo) const; | |
35 int CountChars() const; | |
36 void GetCharInfo(int index, uint32_t& charcode, FX_FLOAT& kerning) const; | |
37 void GetCharInfo(int index, CPDF_TextObjectItem* pInfo) const; | |
38 FX_FLOAT GetCharWidth(uint32_t charcode) const; | |
39 FX_FLOAT GetPosX() const; | |
40 FX_FLOAT GetPosY() const; | |
41 void GetTextMatrix(CFX_Matrix* pMatrix) const; | |
42 CPDF_Font* GetFont() const; | |
43 FX_FLOAT GetFontSize() const; | |
44 | |
45 void SetText(const CFX_ByteString& text); | |
46 void SetPosition(FX_FLOAT x, FX_FLOAT y); | |
47 | |
48 void RecalcPositionData(); | |
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 | |
61 FX_FLOAT m_PosX; | |
62 FX_FLOAT m_PosY; | |
63 int m_nChars; | |
64 uint32_t* m_pCharCodes; | |
65 FX_FLOAT* m_pCharPos; | |
66 }; | |
67 | |
68 #endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_TEXTOBJECT_H_ | |
OLD | NEW |