Jazz2::UI::FormattedTextBlock class

Formatted text block.

Lays out and renders a block of rich text to a canvas, splitting it into parts according to inline formatting, alignment, scale, and spacing. It supports multiline layout with optional word wrapping and ellipsizing to fit given bounds, and caches the computed layout for repeated drawing and measurement.

Public static functions

static auto From(const FormattedTextBlock& source) -> FormattedTextBlock
Returns a copy of the specified instance.

Constructors, destructors, conversion operators

FormattedTextBlock()
Creates a new empty instance.
FormattedTextBlock(const FormattedTextBlockParams& params)
Creates a new instance from the specified parameters.
FormattedTextBlock(const FormattedTextBlock&) deleted
FormattedTextBlock(FormattedTextBlock&& other) noexcept
Creates a new instance by moving the contents of another instance.

Public functions

auto operator=(const FormattedTextBlock&) -> FormattedTextBlock& deleted
auto operator=(FormattedTextBlock&& other) -> FormattedTextBlock& noexcept
void Draw(Canvas* canvas, Rectf bounds, std::uint16_t depth, std::int32_t& charOffset, float angleOffset = 0.0f, float varianceX = 4.0f, float varianceY = 4.0f, float speed = 0.4f)
Draws the text block to the specified canvas within the given bounds.
auto MeasureSize(Vector2f proposedSize) -> Vector2f
Measures the size of the text block for the specified proposed size.
auto GetCachedWidth() const -> float
Returns the cached width of the text block.
auto GetCachedHeight() const -> float
Returns the cached height of the text block.
auto GetAlignment() const -> Alignment
Returns the text alignment.
void SetAlignment(Alignment value)
Sets the text alignment.
auto GetDefaultColor() const -> Colorf
Returns the default text color.
void SetDefaultColor(Colorf color)
Sets the default text color.
auto GetFont() -> Font*
Returns the font used to render the text.
void SetFont(Font* value)
Sets the font used to render the text.
auto GetScale() const -> float
Returns the text scale.
void SetScale(float value)
Sets the text scale.
auto GetCharSpacing() const -> float
Returns the character spacing.
void SetCharSpacing(float value)
Sets the character spacing.
auto GetLineSpacing() const -> float
Returns the line spacing.
void SetLineSpacing(float value)
Sets the line spacing.
auto GetProposedWidth() const -> float constexpr
Returns the proposed width used for layout.
void SetProposedWidth(float value)
Sets the proposed width used for layout.
auto GetText() const -> StringView
Returns the displayed text.
void SetText(StringView value)
Sets the displayed text.
void SetText(String&& value)
auto IsMultiline() const -> bool constexpr
Returns true if multiline text is enabled.
void SetMultiline(bool value)
Sets whether multiline text is enabled.
auto GetWrapping() const -> bool constexpr
Returns true if word wrapping is enabled.
void SetWrapping(bool value)
Sets whether word wrapping is enabled.
auto IsEllipsized() const -> bool constexpr
Returns true if the text is ellipsized to fit the bounds.

Function documentation

void Jazz2::UI::FormattedTextBlock::SetText(String&& value)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.