Foxit PDF SDK

fs_ofdtextobject.h
1 #ifndef FS_OFD_TEXTOBJECT_H_
2 #define FS_OFD_TEXTOBJECT_H_
3
4 #include "common/fs_common.h"
5 #include "fs_ofdgraphicsobject.h"
6
12 namespace foxit {
16 namespace ofd {
17 class TextPieceInfo;
21 namespace graphics {
22 class TextLayout;
23
25 class CharInfo FS_FINAL : public Object {
26 public:
30 CharInfo() :
31 charcode(0),
32 x(0.0f),
33 y(0.0f) {
34 }
42 CharInfo(foxit::uint32 charcode, float x, float y) :
43 charcode(charcode),
44 x(x),
45 y(y){
46 }
47
53 CharInfo& operator=(const CharInfo& other) {
54 charcode = other.charcode;
55 x = other.x;
56 y = other.y;
57
58 return *this;
59 }
60
70 void Set(foxit::uint32 charcode, float x, float y) {
71 this->charcode = charcode;
72 this->x = x;
73 this->y = y;
74 }
75
77 foxit::uint32 charcode;
78
80 float x;
81
83 float y;
84 };
85
87 FSDK_DEFINE_ARRAY(CharInfoArray, CharInfo)
88
89
90 class OFDTextObject FS_FINAL : public OFDGraphicsObject {
91 public:
97 typedef enum _ReadDirectionType {
99 e_ReadDirectionLeftToRight = 0,
101 e_ReadDirectionTopToBottom = 1,
103 e_ReadDirectionRightToLeft = 2,
105 e_ReadDirectionBottomToTop = 3
106 } ReadDirectionType;
107
113 typedef enum _CharDirectionType {
115 e_CharDirectionNormal = 0,
117 e_CharDirectionRight = 1,
119 e_CharDirectionBottom = 2,
121 e_CharDirectionLeft = 3
122 } CharDirectionType;
123
124
130 explicit OFDTextObject(OFDGraphicsObject object);
131
133 ~OFDTextObject();
134
140 OFDTextObject(const OFDTextObject& other);
141
149 OFDTextObject& operator = (const OFDTextObject& other);
150
158 bool operator == (const OFDTextObject& other) const;
159
167 bool operator != (const OFDTextObject& other) const;
168
176 bool IsEmpty() const;
177
183 WString GetFontName();
184
190 float GetFontSize();
191
197 bool IsFill();
198
204 bool IsStroke();
205
211 float GetHScale();
212
219 ReadDirectionType GetReadDirection();
220
227 CharDirectionType GetCharDirection();
228
234 int GetWeight();
235
241 bool IsItalic();
242
248 CharInfoArray GetCharInfo();
249
260 void InsertText(const String& text, float x_pos, float y_pos, bool calculate_width = true);
261
269 void ModifyText(const String& text);
270
276 void AddUnderline();
277
285 void SetFontName(const WString& font_name);
286
294 void SetFontSize(float font_size);
295
303 void SetHScale(float scale);
304
313 void SetReadDirection(ReadDirectionType type);
314
323 void SetCharDirection(CharDirectionType type);
324
332 void SetWeight(int weight);
333
341 void SetItalic(bool italic);
342
352 void SetCharInfos(const foxit::UInt32Array& char_infos, float x, float y);
353
361 void SetTextPieceInfos(const foxit::ofd::TextPieceInfo& text_piece_info);
362
368 TextLayout GetTextLayout();
369
370 explicit OFDTextObject(FS_HANDLE handle);
371 };
372
374 class TextLayout FS_FINAL : public Base {
375 public:
381 typedef enum _LayoutHAlignment {
383 e_LayoutHLeft = 0,
385 e_LayoutHCenter = 1,
387 e_LayoutHRight = 2
388 } LayoutHAlignment;
389
395 typedef enum _LayoutVAlignment {
397 e_LayoutVTop = 0,
399 e_LayoutVCenter = 1,
401 e_LayoutVBottom = 2
402 } LayoutVAlignment;
403
404
406 ~TextLayout();
407
413 TextLayout(const TextLayout& other);
414
422 TextLayout& operator = (const TextLayout& other);
423
431 bool operator == (const TextLayout& other) const;
432
440 bool operator != (const TextLayout& other) const;
441
449 bool IsEmpty() const;
450
457 float GetTextEndOffsetX();
458
465 float GetTextEndOffsetY();
466
474 void SetText(const WString& text);
475
484 void SetRotation(foxit::common::Rotation rotation);
485
493 void SetFontName(const WString& font_name);
494
502 void SetSubFontName(const WString& font_name);
503
511 void SetWeight(int weight);
512
520 void EnableItalic(bool italic);
521
527 void AddUnderline();
528
536 void SetRTFFontSize(float font_size);
537
545 void EnableJustifyX(bool set);
546
554 void EnableJustifyY(bool set);
555
563 void SetLineCharNumer(int num);
564
572 void SetLineBitNumber(int num);
573
581 void SetLineSpace(float space);
582
590 void SetLineBreak(const String& line_break);
591
599 void EnableAutoSize(bool auto_size);
600
608 void EnableVertical(bool vertical);
609
617 void SetFontSize(float font_size);
618
627 void SetHAlignment(LayoutHAlignment align);
628
637 void SetVAlignment(LayoutVAlignment align);
638
646 void EnableMultiline(bool set);
647
653 void Update();
654
655 explicit TextLayout(FS_HANDLE handle);
656 };
657
658 } // namespace graphics
659 } // namespace ofd
660 } // namespace foxit
661
662 #endif // FS_OFD_TEXTOBJECT_H_
foxit::ofd::graphics::TextLayout::GetTextEndOffsetX
float GetTextEndOffsetX()
获取文本对象结束位置相对于boundary在x方向上的偏移量。（富文本排版）
foxit::ofd::graphics::TextLayout::EnableVertical
void EnableVertical(bool vertical)
设置是否垂直排版。
foxit::ofd::graphics::TextLayout::e_LayoutHLeft
水平左对齐。
Definition: fs_ofdtextobject.h:383
foxit::ofd::graphics::TextLayout::Update
void Update()
更新Layout文本对象布局。
foxit::ofd::graphics::TextLayout::e_LayoutVTop
垂直上对齐。
Definition: fs_ofdtextobject.h:397
foxit::ofd::graphics::TextLayout::SetLineCharNumer
void SetLineCharNumer(int num)
设置每行字符数。
foxit::ofd::graphics::TextLayout::operator==
bool operator==(const TextLayout &other) const
相等操作符。
foxit::Object
CFX_Object Object
对象类型。
Definition: fs_basictypes.h:220
foxit::ofd::graphics::TextLayout
Definition: fs_ofdtextobject.h:374
foxit::ofd::graphics::OFDGraphicsObject
Definition: fs_ofdgraphicsobject.h:177
foxit::ofd::graphics::TextLayout::e_LayoutVBottom
垂直底部对齐。
Definition: fs_ofdtextobject.h:401
foxit::ofd::graphics::CharInfoArray
这个类代表 CharInfo 数组。
Definition: fs_ofdtextobject.h:87
foxit::ofd::graphics::CharInfo::Set
void Set(foxit::uint32 charcode, float x, float y)
设置值。
Definition: fs_ofdtextobject.h:70
CFX_WideString
宽字符串类
Definition: fx_string.h:1457
foxit::ofd::graphics::TextLayout::SetText
void SetText(const WString &text)
设置文本内容。
foxit::ofd::graphics::TextLayout::EnableJustifyX
void EnableJustifyX(bool set)
设置水平是否两端对齐。
foxit::ofd::graphics::TextLayout::SetRotation
void SetRotation(foxit::common::Rotation rotation)
设置文字旋转角度。
foxit::ofd::graphics::CharInfo::x
float x
x轴坐标点，左下角点。坐标系为OFD坐标系。
Definition: fs_ofdtextobject.h:80
operator==
bool operator==(const char *str1, const CFX_ByteString &str2)
检查两个字节字符串是否相等。
Definition: fs_basictypes.h:128
foxit::ofd::graphics::TextLayout::SetFontSize
void SetFontSize(float font_size)
设置字体大小。
foxit::ofd::graphics::TextLayout::IsEmpty
bool IsEmpty() const
检查当前对象是否为空。
foxit::ofd::graphics::TextLayout::SetFontName
void SetFontName(const WString &font_name)
设置字体名称。
foxit::ofd::graphics::TextLayout::EnableJustifyY
void EnableJustifyY(bool set)
设置垂直是否两端对齐。
foxit::ofd::graphics::TextLayout::SetSubFontName
void SetSubFontName(const WString &font_name)
设置备选字体名称。
foxit::ofd::graphics::CharInfo::operator=
CharInfo & operator=(const CharInfo &other)
用另一个字符信息的构造函数。
Definition: fs_ofdtextobject.h:53
foxit::ofd::graphics::TextLayout::SetLineBreak
void SetLineBreak(const String &line_break)
设置换行符。
foxit::ofd::graphics::TextLayout::e_LayoutVCenter
垂直中间对齐。
Definition: fs_ofdtextobject.h:399
foxit::ofd::graphics::TextLayout::SetVAlignment
void SetVAlignment(LayoutVAlignment align)
设置垂直对齐方式。
foxit::ofd::graphics::TextLayout::e_LayoutHCenter
水平中间对齐。
Definition: fs_ofdtextobject.h:385
foxit::ofd::graphics::TextLayout::AddUnderline
void AddUnderline()
添加下划线。
foxit::ofd::graphics::TextLayout::e_LayoutHRight
水平右对齐。
Definition: fs_ofdtextobject.h:387
foxit::ofd::graphics::TextLayout::LayoutVAlignment
LayoutVAlignment
文字Layout对象的垂直对齐方式枚举。
Definition: fs_ofdtextobject.h:395
CFX_ArrayTemplate
Definition: fx_basic.h:1278
foxit::uint32
FX_UINT32 uint32
无符号 32 位整数。
Definition: fs_basictypes.h:195
foxit::FS_HANDLE
void * FS_HANDLE
句柄类型。
Definition: fs_basictypes.h:213
fs_common.h
通用定义和类的头文件。
foxit::ofd::graphics::TextLayout::SetWeight
void SetWeight(int weight)
设置字体粗细属性。
foxit::ofd::graphics::CharInfo
Definition: fs_ofdtextobject.h:25
foxit::ofd::graphics::TextLayout::LayoutHAlignment
LayoutHAlignment
文字Layout对象的水平对齐方式枚举。
Definition: fs_ofdtextobject.h:381
foxit::ofd::graphics::TextLayout::TextLayout
TextLayout(const TextLayout &other)
构造函数，通过另一个OFD文本布局对象。
foxit::ofd::graphics::TextLayout::operator !=
bool operator !=(const TextLayout &other) const
不相等操作符。
foxit::ofd::graphics::CharInfo::CharInfo
CharInfo()
构造函数。
Definition: fs_ofdtextobject.h:30
foxit::ofd::graphics::TextLayout::GetTextEndOffsetY
float GetTextEndOffsetY()
获取文本对象结束位置相对于boundary在y方向上的偏移量。（富文本排版）
foxit::ofd::graphics::TextLayout::operator=
TextLayout & operator=(const TextLayout &other)
赋值操作符。
foxit::Base
Definition: fs_basictypes.h:465
foxit::ofd::graphics::TextLayout::EnableItalic
void EnableItalic(bool italic)
设置斜体属性。
foxit::ofd::graphics::TextLayout::~TextLayout
~TextLayout()
析构函数。
foxit::ofd::graphics::TextLayout::SetLineSpace
void SetLineSpace(float space)
设置行间距。
foxit::common::Rotation
Rotation
旋转的枚举。
Definition: fs_common.h:57
foxit
Foxit命名空间。
Definition: fs_taggedpdf.h:27
foxit::ofd::graphics::CharInfo::charcode
foxit::uint32 charcode
字符码。文字的UNICODE编码值。
Definition: fs_ofdtextobject.h:77
CFX_ByteString
字节字符串类
Definition: fx_string.h:317
foxit::ofd::TextPieceInfo
Definition: fs_ofdtextpieceinfo.h:17
foxit::ofd::graphics::TextLayout::SetLineBitNumber
void SetLineBitNumber(int num)
设置每行字节数。
foxit::ofd::graphics::TextLayout::EnableMultiline
void EnableMultiline(bool set)
设置是否需要折行。
foxit::ofd::graphics::TextLayout::SetRTFFontSize
void SetRTFFontSize(float font_size)
设置最大字体大小。（富文本排版）
foxit::ofd::graphics::TextLayout::EnableAutoSize
void EnableAutoSize(bool auto_size)
设置是否自动调整大小。
foxit::ofd::graphics::CharInfo::CharInfo
CharInfo(foxit::uint32 charcode, float x, float y)
带参数的构造函数。
Definition: fs_ofdtextobject.h:42
foxit::ofd::graphics::TextLayout::SetHAlignment
void SetHAlignment(LayoutHAlignment align)
设置水平对齐方式。
foxit::ofd::graphics::OFDTextObject
Definition: fs_ofdtextobject.h:90
foxit::ofd::graphics::CharInfo::y
float y
y轴坐标点，左下角点。坐标系为OFD坐标系。
Definition: fs_ofdtextobject.h:83