51 spans_.push_back(std::move(span));
56 spans_.push_back(std::move(span));
64 spans_.push_back(std::move(span));
73 spans_.push_back(std::move(span));
77 const std::vector<TextSpan>&
spans()
const {
return spans_; }
82 for (
auto& s : spans_)
90 for (
auto& s : spans_)
96 bool empty()
const {
return spans_.empty(); }
99 void clear() { spans_.clear(); }
103 for (
auto& s : spans_) {
104 s.font_family = family;
111 for (
auto& s : spans_)
116 std::vector<TextSpan> spans_;
135 float line_height = 0);
Attributed string — a sequence of styled text spans.
Definition attributed_string.hpp:40
void append(std::string text, Color color)
Append text with specific color.
Definition attributed_string.hpp:60
void append(std::string text)
Append plain text with default styling.
Definition attributed_string.hpp:48
AttributedString(std::string text)
Definition attributed_string.hpp:43
size_t length() const
Total character count.
Definition attributed_string.hpp:88
void clear()
Clear all spans.
Definition attributed_string.hpp:99
void append(TextSpan span)
Append a fully styled span.
Definition attributed_string.hpp:55
AttributedString()=default
void set_font(std::string family, float size)
Set font for all spans.
Definition attributed_string.hpp:102
void set_color(Color color)
Set color for all spans.
Definition attributed_string.hpp:110
bool empty() const
Whether empty.
Definition attributed_string.hpp:96
void append(std::string text, float font_size, Color color)
Append text with specific font size and color.
Definition attributed_string.hpp:68
const std::vector< TextSpan > & spans() const
Get all spans.
Definition attributed_string.hpp:77
std::string plain_text() const
Get the full plain text (concatenated).
Definition attributed_string.hpp:80
Definition affine_transform.hpp:24
TextLayout layout_attributed_string(const AttributedString &text, float max_width, float line_height=0)
Lay out an attributed string within a given width.
@ text
Definition scene_node.hpp:96
TextDecoration
Text decoration style.
Definition attributed_string.hpp:13
@ overline
Definition attributed_string.hpp:13
@ none
Definition attributed_string.hpp:13
@ underline
Definition attributed_string.hpp:13
@ strikethrough
Definition attributed_string.hpp:13
static constexpr Color rgba(float r, float g, float b, float a=1.0f)
Construct from float channels [0,1] (>1.0 allowed for HDR).
Definition canvas.hpp:56
Multi-line text layout result.
Definition attributed_string.hpp:120
float x
Definition attributed_string.hpp:121
float width
Definition attributed_string.hpp:122
std::vector< TextSpan > spans
Definition attributed_string.hpp:123
float y
Definition attributed_string.hpp:121
float height
Definition attributed_string.hpp:122
Definition attributed_string.hpp:126
std::vector< TextLayoutLine > lines
Definition attributed_string.hpp:127
float total_height
Definition attributed_string.hpp:129
float total_width
Definition attributed_string.hpp:128
A span of text with consistent styling.
Definition attributed_string.hpp:16
int font_slant
Definition attributed_string.hpp:22
TextDecoration decoration
Definition attributed_string.hpp:24
float letter_spacing
Definition attributed_string.hpp:30
bool italic
Definition attributed_string.hpp:21
std::string text
Definition attributed_string.hpp:17
bool inherit_letter_spacing
Definition attributed_string.hpp:36
Color color
Definition attributed_string.hpp:23
bool inherit_color
Definition attributed_string.hpp:35
bool inherit_font_weight
Definition attributed_string.hpp:33
std::string font_family
Definition attributed_string.hpp:18
Color decoration_color
Definition attributed_string.hpp:29
int font_weight
Definition attributed_string.hpp:20
bool decoration_override
Definition attributed_string.hpp:28
bool inherit_font_family
Definition attributed_string.hpp:31
bool inherit_font_slant
Definition attributed_string.hpp:34
float font_size
Definition attributed_string.hpp:19
bool inherit_font_size
Definition attributed_string.hpp:32