Text Class Documentation
class Text : ElementNamespace:datalogics_interface
- Inherits from:
Element
Detailed Description
A container that represents a series of text elements and characters.
A Text object is container that represents both a series of TextRun elements and a series of text characters. Operations can be performed on individual TextRuns within a Text or on individual characters within a Text by specifying the index of the individual TextRun or character. All indices start at 0.
Referenced by
Constructor & Destructor Documentation
Member Function Documentation
add_glyphs
void add_glyphs(const std::vector< std::uint8_t > & glyph_ids, const std::vector< std::uint8_t > & uni_text, Font & font, GraphicState & gs, TextState & ts, const Matrix & matrix, TextFlags flags)Parameters
glyph_ids: const std::vector< std::uint8_t > &Glyphs IDs in the specified font for adding to the page's content
uni_text: const std::vector< std::uint8_t > &Unicode codes for the specified glyph IDs
font: Font &- Font for wich GlyphIDs were specified
gs: GraphicState &- The GraphicsState for Text element
ts: TextState &- TextState flags
matrix: const Matrix &- matrix for the Text element
flags: TextFlags- TextFlags that specifies what kind of text to add
Returns:
voidAdds Unicode text to a Text object
add_glyphs
void add_glyphs(const std::vector< std::uint8_t > & glyph_ids, const std::vector< std::uint8_t > & uni_text, Font & font, GraphicState & gs, TextState & ts, const Matrix & matrix, TextFlags flags, int index)Parameters
glyph_ids: const std::vector< std::uint8_t > &Glyphs IDs in the specified font for adding to the page's content
uni_text: const std::vector< std::uint8_t > &Unicode codes for the specified glyph IDs
font: Font &- Font for wich GlyphIDs were specified
gs: GraphicState &- The GraphicsState for Text element
ts: TextState &- TextState flags
matrix: const Matrix &- matrix for the Text element
flags: TextFlags- TextFlags that specifies what kind of text to add
index: int
Returns:
voidAdds Unicode text to a Text object
add_run
void add_run(TextRun & run)Parameters
run: TextRun &The TextRun to append.
Returns:
voidAdds a TextRun to the end of this text element.
add_run
void add_run(TextRun & run, int index)Parameters
run: TextRun &The TextRun to append.
index: int
Returns:
voidAdds a TextRun to the end of this text element.
change_text_matrix_for_text_run
void change_text_matrix_for_text_run(const Matrix & new_matrix, int text_run_index)Parameters
new_matrix: const Matrix &The new transformation matrix to use for the TextRun.
text_run_index: intThe index of a TextRun, relative to the Text object (the first TextRun in the Text object is at index 0).
Returns:
voidChanges the transformation matrix from user space to the current text space for the specified TextRun. The H and V values of the matrix indicate the origin of the first character.
clone
std::unique_ptr< Element > clone(ElementCloneFlags flags)Parameters
flags: ElementCloneFlags
Returns:
std::unique_ptr< Element >The copied element.
Makes a copy of the element.
Make a copy of an element to obtain a new element that has a distinct set of attributes.
Note: TextRun objects may not be cloned.
clone
std::unique_ptr< Text > clone()Returns:
std::unique_ptr< Text >Makes a copy of this Text object.
find_text_run_index_for_character
int find_text_run_index_for_character(int char_index)Parameters
char_index: intThe index of a character, relative to the Text object (the first character in the Text object is at index 0).
Returns:
intThe index of the TextRun that contains the character specified by characterIndex.
Finds the index of the TextRun that contains the nth character in a Text object.
get_advance_for_character
Point get_advance_for_character(int index)Parameters
index: intThe index of a character, relative to the Text object (the first character in the Text object is at index 0).
Returns:
PointA value specifying both the horizontal and vertical components of the advance width of a character in user space.
Gets the advance width of a character, in user space. The advance width is the amount by which the current point advances when the character is drawn.
Advance width may be horizontal or vertical, depending on the writing style. Thus, the return value has both a horizontal and a vertical component.
get_advance_for_text_run
Point get_advance_for_text_run(int index)Parameters
index: intThe index of a TextRun, relative to the Text object (the first TextRun in the Text object is at index 0).
Returns:
PointA value specifying both the horizontal and vertical components of the advance width of a TextRun in user space.
Gets the advance width of a TextRun, in user space. The advance width is the amount by which the current point advances when the TextRun is drawn.
Advance width may be horizontal or vertical, depending on the writing style. Thus, the return value has both a horizontal and a vertical component.
get_bounding_box
Rect get_bounding_box()Returns:
RectThe bounding box for this element. The coordinates of the bounding box are specified in user space coordinates, relative to the element's Content. Note that user space coordinates correspond to unrotated pages; any rotation specified in the page dictionary is not taken into account.
The bounding box for this element.
The bounding box is a rectangle that is guaranteed to encompass the element, but it is not guaranteed to be the smallest box that could contain the element. For example, if the element is a Path that contains an arc, the bounding box encompasses the bezier control points, and not just the curve itself.
get_bounding_box_for_character
Rect get_bounding_box_for_character(int index)Parameters
index: intThe index of a character, relative to the Text object (the first character in the Text object is at index 0)
Returns:
RectA Rect specifying the bounding box for the character.
The bounding box for a character in this text element.
get_clip
std::unique_ptr< Clip > get_clip()Returns:
std::unique_ptr< Clip >The current Clip for this Element, or NULL if no clip is set.
Gets the current Clip for an Element.
get_element_type
ElementType get_element_type()Returns:
ElementTypeReturns the runtime type of this element.
get_matrix
Matrix get_matrix()Returns:
MatrixThe current transformation matrix applied to this element.
The transformation matrix for the element.
get_number_of_characters
int get_number_of_characters()Returns:
intThe number of characters in this text element.
get_number_of_runs
int get_number_of_runs()Returns:
intThe number of text runs in this text element.
get_run
std::unique_ptr< TextRun > get_run(int index)Parameters
index: intThe zero-based index of the TextRun to retrieve.
Returns:
std::unique_ptr< TextRun >The TextRun at the specified index.
Obtains the TextRun at the specified index.
get_text_matrix_for_character
Matrix get_text_matrix_for_character(int index)Parameters
index: intThe index of a character, relative to the Text object (the first character in the Text object is at index 0).
Returns:
MatrixThe transformation matrix for the character specified by characterIndex.
Gets the transformation matrix from user space to the current text space for the specified character. The H and V values of the matrix indicate the origin of the first character.
get_text_matrix_for_text_run
Matrix get_text_matrix_for_text_run(int index)Parameters
index: intThe index of a TextRun, relative to the Text object (the first TextRun in the Text object is at index 0).
Returns:
MatrixThe transformation matrix for the TextRun specified by TextRunIndex.
Gets the transformation matrix from user space to the current text space for the specified TextRun. The H and V values of the matrix indicate the origin of the first character.
operator=
Parameters
: Text &&
Returns:
Text &point_intersects_character
bool point_intersects_character(const Point & p, int index)Parameters
p: const Point &The point to test, in user space coordinates.
index: intThe index of the character. The first character in the Text has an index of 0.
Returns:
booltrue if the point is on the character, false if the point is not on the character.
Tests whether a point is on a specified character within this Text object.
point_intersects_text_run
bool point_intersects_text_run(const Point & p, int index)Parameters
p: const Point &The point to test, in user space coordinates.
index: intThe index of the TextRun. The first TextRun in the Text has an index of 0.
Returns:
booltrue if the point is on the TextRun, false if the point is not on the TextRun.
Tests whether a point is on a specified TextRun within this Text object.
rect_intersects_character
bool rect_intersects_character(const Rect & r, int index)Parameters
r: const Rect &The rect to test, in user space coordinates.
index: intThe index of the character. The first character in the Text has an index of 0.
Returns:
booltrue if any part of the rectangle is on the character, false if no part of the rectangle is on the character.
Tests whether any part of a rectangle is on a specified character within this Text object.
rect_intersects_text_run
bool rect_intersects_text_run(const Rect & r, int index)Parameters
r: const Rect &The rect to test, in user space coordinates.
index: intThe index of the TextRun. The first TextRun in the Text has an index of 0.
Returns:
booltrue if any part of the rectangle is on the TextRun, false if no part of the rectangle is on the TextRun.
Tests whether any part of a rectangle is on a specified TextRun within this Text object.
remove_runs
void remove_runs(int index, int count)Parameters
index: intStart position of range to delete
count: intCount of TextRuns to delete
Returns:
voidRemoves a count of TextRuns, starting from index
rotate
void rotate(double theta)Parameters
theta: doubleThe rotation angle in degrees.
Returns:
voidRotate an element by theta degrees counterclockwise using the matrix [ cos T sin T -sin T cos T 0 0 ].
scale
void scale(double sx, double sy)Parameters
sx: doubleThe horizontal scale factor.
sy: doubleThe vertical scale factor.
Returns:
voidScale an element by (sx,sy) units using the matrix [ sx 0 0 sy 0 0 ].
set_clip
void set_clip(Clip & clip)Parameters
clip: Clip &The clip to set as the current clip for this element, or NULL to remove clipping.
Returns:
voidSets the current Clip for an Element.
set_matrix
void set_matrix(const Matrix & matrix)Parameters
matrix: const Matrix &The transformation matrix for the element.
Returns:
voidSet the transformation matrix for the element.
split_text_run_at_character
void split_text_run_at_character(int split_location)Parameters
split_location: intThe split location, relative to the Text object.
Returns:
voidSplits the TextRun containing the character at the specified location into two contiguous TextRuns. The character at the specified index will be part of the first TextRun.
translate
void translate(double tx, double ty)Parameters
tx: doubleThe horizontal translation distance in user space units.
ty: doubleThe vertical translation distance in user space units.
Returns:
voidTranslate an element by (tx,ty) units using the matrix [ 1 0 0 1 tx ty ].
try_as
T * try_as(typename T )Parameters
: typename T
Returns:
T *Attempt to downcast this element to a derived type. Returns a pointer to the derived type, or nullptr if the type doesn't match.
try_as
const T * try_as(typename T )Parameters
: typename T
Returns:
const T *Const overload of try_as(). Returns a const pointer, or nullptr.