Text Class Documentation

class Text : Element

Namespace: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

Text

Text()

Create a new, empty Text object.

~Text

~Text()

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:

void

Adds 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:

void

Adds Unicode text to a Text object

add_run

void add_run(TextRun & run)

Parameters

run: TextRun &

The TextRun to append.

Returns:

void

Adds 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:

void

Adds 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: int

The index of a TextRun, relative to the Text object (the first TextRun in the Text object is at index 0).

Returns:

void

Changes 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.

find_text_run_index_for_character

int find_text_run_index_for_character(int char_index)

Parameters

char_index: int

The index of a character, relative to the Text object (the first character in the Text object is at index 0).

Returns:

int

The 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: int

The index of a character, relative to the Text object (the first character in the Text object is at index 0).

Returns:

Point

A 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: int

The index of a TextRun, relative to the Text object (the first TextRun in the Text object is at index 0).

Returns:

Point

A 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:

Rect

The 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: int

The index of a character, relative to the Text object (the first character in the Text object is at index 0)

Returns:

Rect

A Rect specifying the bounding box for the character.

The bounding box for a character in this text element.

get_matrix

Matrix get_matrix()

Returns:

Matrix

The current transformation matrix applied to this element.

The transformation matrix for the element.

get_number_of_characters

int get_number_of_characters()

Returns:

int

The number of characters in this text element.

get_number_of_runs

int get_number_of_runs()

Returns:

int

The number of text runs in this text element.

get_text_matrix_for_character

Matrix get_text_matrix_for_character(int index)

Parameters

index: int

The index of a character, relative to the Text object (the first character in the Text object is at index 0).

Returns:

Matrix

The 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: int

The index of a TextRun, relative to the Text object (the first TextRun in the Text object is at index 0).

Returns:

Matrix

The 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.

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: int

The index of the character. The first character in the Text has an index of 0.

Returns:

bool

true 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: int

The index of the TextRun. The first TextRun in the Text has an index of 0.

Returns:

bool

true 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: int

The index of the character. The first character in the Text has an index of 0.

Returns:

bool

true 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: int

The index of the TextRun. The first TextRun in the Text has an index of 0.

Returns:

bool

true 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: int

Start position of range to delete

count: int

Count of TextRuns to delete

Returns:

void

Removes a count of TextRuns, starting from index

rotate

void rotate(double theta)

Parameters

theta: double

The rotation angle in degrees.

Returns:

void

Rotate 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: double

The horizontal scale factor.

sy: double

The vertical scale factor.

Returns:

void

Scale 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:

void

Sets 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:

void

Set the transformation matrix for the element.

split_text_run_at_character

void split_text_run_at_character(int split_location)

Parameters

split_location: int

The split location, relative to the Text object.

Returns:

void

Splits 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: double

The horizontal translation distance in user space units.

ty: double

The vertical translation distance in user space units.

Returns:

void

Translate 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.