![]() |
ThorVG
v0.13
|
A class to represent text objects in a graphical context, allowing for rendering and manipulation of unicode text. More...
Public Member Functions | |
Result | font (const char *name, float size, const char *style=nullptr) noexcept |
Sets the font properties for the text. More... | |
Result | text (const char *text) noexcept |
Assigns the given unicode text to be rendered. More... | |
Result | fill (uint8_t r, uint8_t g, uint8_t b) noexcept |
Sets the text color. More... | |
Result | fill (std::unique_ptr< Fill > f) noexcept |
Sets the gradient fill for all of the figures from the text. More... | |
![]() | |
Result | rotate (float degree) noexcept |
Sets the angle by which the object is rotated. More... | |
Result | scale (float factor) noexcept |
Sets the scale value of the object. More... | |
Result | translate (float x, float y) noexcept |
Sets the values by which the object is moved in a two-dimensional space. More... | |
Result | transform (const Matrix &m) noexcept |
Sets the matrix of the affine transformation for the object. More... | |
Matrix | transform () noexcept |
Gets the matrix of the affine transformation of the object. More... | |
Result | opacity (uint8_t o) noexcept |
Sets the opacity of the object. More... | |
Result | composite (std::unique_ptr< Paint > target, CompositeMethod method) noexcept |
Sets the composition target object and the composition method. More... | |
Result | blend (BlendMethod method) const noexcept |
Sets the blending method for the paint object. More... | |
TVG_DEPRECATED Result | bounds (float *x, float *y, float *w, float *h) const noexcept |
Gets the bounding box of the paint object before any transformation. More... | |
Result | bounds (float *x, float *y, float *w, float *h, bool transformed) const noexcept |
Gets the axis-aligned bounding box of the paint object. More... | |
Paint * | duplicate () const noexcept |
Duplicates the object. More... | |
uint8_t | opacity () const noexcept |
Gets the opacity value of the object. More... | |
CompositeMethod | composite (const Paint **target) const noexcept |
Gets the composition target object and the composition method. More... | |
BlendMethod | blend () const noexcept |
Gets the blending method of the object. More... | |
uint32_t | identifier () const noexcept |
Return the unique id value of the paint instance. More... | |
Static Public Member Functions | |
static Result | load (const std::string &path) noexcept |
Loads a scalable font data(ttf) from a file. More... | |
static Result | unload (const std::string &path) noexcept |
Unloads the specified scalable font data (TTF) that was previously loaded. More... | |
static std::unique_ptr< Text > | gen () noexcept |
Creates a new Text object. More... | |
static uint32_t | identifier () noexcept |
Return the unique id value of this class. More... | |
A class to represent text objects in a graphical context, allowing for rendering and manipulation of unicode text.
Sets the gradient fill for all of the figures from the text.
The parts of the text defined as inner are filled.
[in] | f | The unique pointer to the gradient fill. |
Result::Success | when succeed, Result::MemoryCorruption otherwise. |
Result::InsufficientCondition | when the font has not been set up prior to this operation. |
|
noexcept |
Sets the text color.
[in] | r | The red color channel value in the range [0 ~ 255]. The default value is 0. |
[in] | g | The green color channel value in the range [0 ~ 255]. The default value is 0. |
[in] | b | The blue color channel value in the range [0 ~ 255]. The default value is 0. |
Result::Success | when succeed. |
Result::InsufficientCondition | when the font has not been set up prior to this operation. |
|
noexcept |
Sets the font properties for the text.
This function allows you to define the font characteristics used for text rendering. It sets the font name, size and optionally the style.
[in] | name | The name of the font. This should correspond to a font available in the canvas. |
[in] | size | The size of the font in points. This determines how large the text will appear. |
[in] | style | The style of the font. It can be used to set the font to 'italic'. If not specified, the default style is used. Only 'italic' style is supported currently. |
Result::Success | when the font properties are set successfully. |
Result::InsufficientCondition | when the specified name cannot be found. |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
Loads a scalable font data(ttf) from a file.
ThorVG efficiently caches the loaded data using the specified path
as a key. This means that loading the same file again will not result in duplicate operations; instead, ThorVG will reuse the previously loaded font data.
[in] | path | The path to the font file. |
Result::Success | When succeed. |
Result::InvalidArguments | In case the path is invalid. |
Result::NonSupport | When trying to load a file with an unknown extension. |
Result::Unknown | If an error occurs at a later stage. |
|
noexcept |
Assigns the given unicode text to be rendered.
This function sets the unicode string that will be displayed by the rendering system. The text is set according to the specified UTF encoding method, which defaults to UTF-8.
[in] | text | The multi-byte text encoded with utf8 string to be rendered. |
Result::Success | when succeed. |
|
staticnoexcept |
Unloads the specified scalable font data (TTF) that was previously loaded.
This function is used to release resources associated with a font file that has been loaded into memory.
[in] | path | The file path of the loaded font. |
Result::Success | Successfully unloads the font data. |
Result::InsufficientCondition | Fails if the loader is not initialized. |