Unravel Engine C++ Reference
Loading...
Searching...
No Matches
unravel::text_component Class Reference

#include <text_component.h>

Inheritance diagram for unravel::text_component:
unravel::component_crtp< text_component > unravel::basic_component

Public Types

enum class  buffer_type : uint32_t { static_buffer , dynamic_buffer , transient_buffer }
 
enum class  overflow_type : uint32_t { none , word , grapheme }
 
- Public Types inherited from unravel::component_crtp< text_component >
using base
 

Public Member Functions

void set_text (const std::string &text)
 Sets the text content to be rendered.
 
auto get_text () const -> const std::string &
 Gets the current text content.
 
void set_style (const text_style &style)
 Sets the text styling properties.
 
auto get_style () const -> const text_style &
 Gets the current text style settings.
 
void set_buffer_type (const buffer_type &type)
 Sets the buffer type for text rendering.
 
auto get_buffer_type () const -> const buffer_type &
 Gets the current buffer type.
 
void set_overflow_type (const overflow_type &type)
 Sets how text should overflow when it exceeds its bounds.
 
auto get_overflow_type () const -> const overflow_type &
 Gets the current overflow handling type.
 
void set_font (const asset_handle< font > &font)
 Sets the font to be used for rendering text.
 
auto get_font () const -> const asset_handle< font > &
 Gets the current font.
 
void set_font_size (uint32_t font_size)
 Sets the font size in pixels.
 
auto get_font_size () const -> uint32_t
 Gets the current font size.
 
void set_auto_size (bool auto_size)
 Enables or disables automatic font sizing.
 
auto get_auto_size () const -> bool
 Checks if auto-sizing is enabled.
 
auto get_render_font_size () const -> uint32_t
 Gets the actual font size being used for rendering.
 
void set_area (const fsize_t &area)
 Sets the area bounds for text rendering.
 
auto get_area () const -> const fsize_t &
 Gets the current text area bounds.
 
void set_auto_size_range (const urange32_t &range)
 Sets the range for automatic font sizing.
 
auto get_auto_size_range () const -> const urange32_t &
 Gets the current auto-size range.
 
void set_is_rich_text (bool is_rich)
 Enables or disables rich text processing.
 
auto get_is_rich_text () const -> bool
 Checks if rich text processing is enabled.
 
void set_apply_kerning (bool apply_kerning)
 Enables or disables kerning in text rendering.
 
auto get_apply_kerning () const -> bool
 Checks if kerning is enabled.
 
void set_alignment (const alignment &align)
 Sets the text alignment properties.
 
auto get_alignment () const -> const alignment &
 Gets the current text alignment settings.
 
auto get_scaled_font () const -> const scaled_font &
 Gets the scaled font instance used for rendering.
 
auto get_render_area () const -> fsize_t
 Gets the actual area used for rendering.
 
auto can_be_rendered () const -> bool
 Checks if the text can be rendered.
 
auto get_bounds () const -> math::bbox
 Gets the bounding box of the text.
 
auto get_render_bounds () const -> math::bbox
 Gets the bounding box used for rendering.
 
auto get_render_buffers_count () const -> size_t
 Gets the number of render buffers being used.
 
auto get_lines (bool include_breaks=true) const -> text_vector< text_line >
 Gets the text content split into lines.
 
auto meters_to_px (float meters) const -> float
 Converts meters to pixels based on current font metrics.
 
auto px_to_meters (float px) const -> float
 Converts pixels to meters based on current font metrics.
 
void submit (gfx::view_id id, const math::transform &world, uint64_t state)
 Submits the text for rendering.
 
- Public Member Functions inherited from unravel::basic_component
void touch ()
 Marks the component as 'touched'.
 

Additional Inherited Members

- Public Attributes inherited from unravel::basic_component
bool eto {}
 Disable empty type optimizations.
 
- Static Public Attributes inherited from unravel::component_crtp< text_component >
static constexpr bool in_place_delete
 Indicates if the component can be deleted in place.
 

Detailed Description

Definition at line 185 of file text_component.h.

Member Enumeration Documentation

◆ buffer_type

enum class unravel::text_component::buffer_type : uint32_t
strong
Enumerator
static_buffer 
dynamic_buffer 
transient_buffer 

Definition at line 188 of file text_component.h.

◆ overflow_type

enum class unravel::text_component::overflow_type : uint32_t
strong
Enumerator
none 
word 
grapheme 

Definition at line 195 of file text_component.h.

Member Function Documentation

◆ can_be_rendered()

auto unravel::text_component::can_be_rendered ( ) const -> bool

Checks if the text can be rendered.

Returns
True if the text can be rendered, false otherwise

Definition at line 1320 of file text_component.cpp.

◆ get_alignment()

auto unravel::text_component::get_alignment ( ) const -> const alignment&

Gets the current text alignment settings.

Returns
The current alignment flags

Definition at line 1214 of file text_component.cpp.

◆ get_apply_kerning()

auto unravel::text_component::get_apply_kerning ( ) const -> bool

Checks if kerning is enabled.

Returns
True if kerning is enabled, false otherwise

Definition at line 1198 of file text_component.cpp.

◆ get_area()

auto unravel::text_component::get_area ( ) const -> const fsize_t&

Gets the current text area bounds.

Returns
The current width and height of the text area

Definition at line 1230 of file text_component.cpp.

◆ get_auto_size()

auto unravel::text_component::get_auto_size ( ) const -> bool

Checks if auto-sizing is enabled.

Returns
True if auto-sizing is enabled, false otherwise

Definition at line 1161 of file text_component.cpp.

◆ get_auto_size_range()

auto unravel::text_component::get_auto_size_range ( ) const -> const urange32_t&

Gets the current auto-size range.

Returns
The current minimum and maximum font sizes for auto-sizing

Definition at line 1246 of file text_component.cpp.

◆ get_bounds()

auto unravel::text_component::get_bounds ( ) const -> math::bbox

Gets the bounding box of the text.

Returns
The bounding box in local space

Definition at line 1251 of file text_component.cpp.

◆ get_buffer_type()

auto unravel::text_component::get_buffer_type ( ) const -> const buffer_type&

Gets the current buffer type.

Returns
The current buffer_type being used

Definition at line 962 of file text_component.cpp.

◆ get_font()

auto unravel::text_component::get_font ( ) const -> const asset_handle<font>&

Gets the current font.

Returns
Asset handle to the current font

Definition at line 992 of file text_component.cpp.

◆ get_font_size()

auto unravel::text_component::get_font_size ( ) const -> uint32_t

Gets the current font size.

Returns
The current font size in pixels

Definition at line 1145 of file text_component.cpp.

◆ get_is_rich_text()

auto unravel::text_component::get_is_rich_text ( ) const -> bool

Checks if rich text processing is enabled.

Returns
True if rich text is enabled, false otherwise

Definition at line 1182 of file text_component.cpp.

◆ get_lines()

auto unravel::text_component::get_lines ( bool include_breaks = true) const -> text_vector<text_line>

Gets the text content split into lines.

Parameters
include_breaksWhether to include line break symbols in the output
Returns
Vector of text lines with their break symbols

Definition at line 1286 of file text_component.cpp.

◆ get_overflow_type()

auto unravel::text_component::get_overflow_type ( ) const -> const overflow_type&

Gets the current overflow handling type.

Returns
The current overflow_type being used

Definition at line 976 of file text_component.cpp.

◆ get_render_area()

auto unravel::text_component::get_render_area ( ) const -> fsize_t

Gets the actual area used for rendering.

Returns
The calculated render area dimensions

Definition at line 1328 of file text_component.cpp.

◆ get_render_bounds()

auto unravel::text_component::get_render_bounds ( ) const -> math::bbox

Gets the bounding box used for rendering.

Returns
The bounding box in render space

Definition at line 1266 of file text_component.cpp.

◆ get_render_buffers_count()

auto unravel::text_component::get_render_buffers_count ( ) const -> size_t

Gets the number of render buffers being used.

Returns
The count of render buffers

Definition at line 1281 of file text_component.cpp.

◆ get_render_font_size()

auto unravel::text_component::get_render_font_size ( ) const -> uint32_t

Gets the actual font size being used for rendering.

Returns
The calculated font size in pixels

Definition at line 1166 of file text_component.cpp.

◆ get_scaled_font()

auto unravel::text_component::get_scaled_font ( ) const -> const scaled_font&

Gets the scaled font instance used for rendering.

Returns
Reference to the current scaled font

Definition at line 997 of file text_component.cpp.

◆ get_style()

auto unravel::text_component::get_style ( ) const -> const text_style&

Gets the current text style settings.

Returns
The current text_style object

Definition at line 948 of file text_component.cpp.

◆ get_text()

auto unravel::text_component::get_text ( ) const -> const std::string&

Gets the current text content.

Returns
The current text string being rendered

Definition at line 933 of file text_component.cpp.

◆ meters_to_px()

auto unravel::text_component::meters_to_px ( float meters) const -> float

Converts meters to pixels based on current font metrics.

Parameters
metersThe value in meters to convert
Returns
The equivalent value in pixels

Definition at line 1311 of file text_component.cpp.

◆ px_to_meters()

auto unravel::text_component::px_to_meters ( float px) const -> float

Converts pixels to meters based on current font metrics.

Parameters
pxThe value in pixels to convert
Returns
The equivalent value in meters

Definition at line 1315 of file text_component.cpp.

◆ set_alignment()

void unravel::text_component::set_alignment ( const alignment & align)

Sets the text alignment properties.

Parameters
alignThe alignment flags for horizontal and vertical positioning

Definition at line 1203 of file text_component.cpp.

◆ set_apply_kerning()

void unravel::text_component::set_apply_kerning ( bool apply_kerning)

Enables or disables kerning in text rendering.

Parameters
apply_kerningTrue to enable kerning, false to disable

Definition at line 1187 of file text_component.cpp.

◆ set_area()

void unravel::text_component::set_area ( const fsize_t & area)

Sets the area bounds for text rendering.

Parameters
areaThe width and height of the text area

Definition at line 1219 of file text_component.cpp.

◆ set_auto_size()

void unravel::text_component::set_auto_size ( bool auto_size)

Enables or disables automatic font sizing.

Parameters
auto_sizeTrue to enable auto-sizing, false to disable

Definition at line 1150 of file text_component.cpp.

◆ set_auto_size_range()

void unravel::text_component::set_auto_size_range ( const urange32_t & range)

Sets the range for automatic font sizing.

Parameters
rangeThe minimum and maximum font sizes allowed

Definition at line 1235 of file text_component.cpp.

◆ set_buffer_type()

void unravel::text_component::set_buffer_type ( const buffer_type & type)

Sets the buffer type for text rendering.

Parameters
typeThe buffer_type to use (static, dynamic, or transient)

Definition at line 953 of file text_component.cpp.

◆ set_font()

void unravel::text_component::set_font ( const asset_handle< font > & font)

Sets the font to be used for rendering text.

Parameters
fontAsset handle to the font resource

Definition at line 981 of file text_component.cpp.

◆ set_font_size()

void unravel::text_component::set_font_size ( uint32_t font_size)

Sets the font size in pixels.

Parameters
font_sizeThe size in pixels

Definition at line 1134 of file text_component.cpp.

◆ set_is_rich_text()

void unravel::text_component::set_is_rich_text ( bool is_rich)

Enables or disables rich text processing.

Parameters
is_richTrue to enable rich text processing, false for plain text

Definition at line 1171 of file text_component.cpp.

◆ set_overflow_type()

void unravel::text_component::set_overflow_type ( const overflow_type & type)

Sets how text should overflow when it exceeds its bounds.

Parameters
typeThe overflow_type to use (none, word, or grapheme)

Definition at line 967 of file text_component.cpp.

◆ set_style()

void unravel::text_component::set_style ( const text_style & style)

Sets the text styling properties.

Parameters
styleThe text_style object containing all styling properties

Definition at line 938 of file text_component.cpp.

◆ set_text()

void unravel::text_component::set_text ( const std::string & text)

Sets the text content to be rendered.

Parameters
textThe string content to be displayed

Definition at line 923 of file text_component.cpp.

◆ submit()

void unravel::text_component::submit ( gfx::view_id id,
const math::transform & world,
uint64_t state )

Submits the text for rendering.

Parameters
idThe view ID for rendering
worldThe world transform matrix
stateThe rendering state flags

Definition at line 1364 of file text_component.cpp.


The documentation for this class was generated from the following files: