Text Params
Encapsulates all parameters for rendering text as an image.
The TextParams class defines the configuration needed to generate a bitmap of text. It includes options for:
Content and Styling: The text content, its size, color, and font properties (custom font, weight, and style).
Dimensions: Explicit width/height as well as maximum allowed width/height. If explicit dimensions are not provided, the layout is computed based on the text content and padding.
Layout and Spacing: Padding around the text, additional line spacing, text alignment, and the maximum number of lines to render.
Borders and Background: Border width, border color, corner radius for the border, transparency flag, and an optional background color.
You can conveniently configure these properties using the fluent setter methods.
Important Notes:
Not all fonts support every combination of weight and style. In such cases, the system may substitute or approximate the requested configuration.
If a custom font is specified via setCustomFont, ensure that the asset path provided (e.g.,
"fonts/CustomFont.ttf") is correct and that the font file exists in the assets folder.
Properties
An optional background color for the text image. If set, it overrides transparency.
The color of the border.
The corner radius for the border.
The width of the border drawn around the text image.
An optional custom font (FontFamily) to use for rendering the text.
The weight of the font.
A flag indicating whether the image background should be transparent.
Additional spacing between lines of text.
Functions
Sets the text alignment.
Sets the background color for the image.
Sets the color of the border.
Sets the corner radius for the border.
Sets the width of the border drawn around the text image.
Sets a custom font to be used when rendering the text.
Sets the style for the font (e.g., italic, normal).
Sets the weight for the font.
Sets the explicit height for the text layout.
Sets the line spacing for the text.
Sets the maximum height for the text layout.
Sets the maximum number of lines for the text.
Sets the maximum width for the text layout.
Sets the padding for the text layout.
Sets the text content.
Sets the text color.
Sets the text size.
Sets the transparency flag for the image.
Sets the explicit width for the text layout.
Calculates the total padding for the layout.