1.1.0
Public Member Functions | Public Attributes | List of all members
fc::render_result Struct Reference

Wraps a std::vector<fc_character_mapping>. More...

#include <render-result.hpp>

Public Member Functions

 render_result (fc_font *font=nullptr, std::vector< fc_character_mapping > &&mapping={})
 Constructs a fc::render_result instance with a font and with a mapping vector. More...
 
 render_result (render_result &&other) noexcept
 Move constructor of fc::render_result. More...
 
render_resultoperator= (render_result &&other) noexcept
 Move assignment operator for fc::render_result. More...
 
render_resultoperator= (render_result const &other) noexcept
 Copy assignment operator for fc::render_result. More...
 
render_resultwrap (float line_width, float line_height_multiplier=1.0f, fc_alignment alignment=fc_align_left) &
 Calls fc_wrap on the vector of character mappings. More...
 
render_result && wrap (float line_width, float line_height_multiplier=1.0f, fc_alignment alignment=fc_align_left) &&
 Calls fc_wrap on the vector of character mappings. More...
 
render_resultmove (float left=0.0f, float baseline=0.0f) &
 This is a wrapper to fc_move. Consult its documentation for more information. More...
 
render_result && move (float left=0.0f, float baseline=0.0f) &&
 This is a wrapper to fc_move. Consult its documentation for more information. More...
 
std::vector<::fc_character_mapping >::iterator begin ()
 Returns an iterator pointing to the first character mapping. More...
 
std::vector<::fc_character_mapping >::iterator end ()
 Returns an iterator pointing to the end+1 character mapping. More...
 
size_t size () const
 Returns the size of the mapping vector (i.e, the number of mappings) More...
 

Public Attributes

std::vector<::fc_character_mappingmapping
 A vector of character mappings produced after calling fc::font::render.
 
uint32_t line_count
 How many lines were produced.
 
fc_fontfont
 A pointer to the fc_font used to generate this mapping.
 

Detailed Description

Wraps a std::vector<fc_character_mapping>.

It's mainly a quality of life improvement over working with a vector directly. It supports move semantics to allow for method chaining and it also supports iterators and range-based for loops.

Example

fc::font font; // suppose a font that has already been cooked
fc::render_result result = font.render("Hello world!").wrap(100.0f).move(0.0f, 50.0f);
Examples
main.cpp.

Constructor & Destructor Documentation

◆ render_result() [1/2]

fc::render_result::render_result ( fc_font font = nullptr,
std::vector< fc_character_mapping > &&  mapping = {} 
)
inline

Constructs a fc::render_result instance with a font and with a mapping vector.

This constructor exists mainly to be used by fc::font::render. You probably will never use it directly.

Parameters
fontThe font used to generate the contained mapping
mappingA movable reference to a vector of character mappings
See also
fc::font::render

◆ render_result() [2/2]

fc::render_result::render_result ( render_result &&  other)
inlinenoexcept

Move constructor of fc::render_result.

Parameters
otherA rvalue (moveable) ref to a fc::render_result instance

Member Function Documentation

◆ operator=() [1/2]

render_result& fc::render_result::operator= ( render_result &&  other)
inlinenoexcept

Move assignment operator for fc::render_result.

Parameters
otherA rvalue (moveable) ref to a fc::render_result instance
Returns
*this

◆ operator=() [2/2]

render_result& fc::render_result::operator= ( render_result const &  other)
inlinenoexcept

Copy assignment operator for fc::render_result.

Parameters
otherA const lvalue (non-moveable) ref to a fc::render_result instance
Returns
*this

◆ wrap() [1/2]

render_result& fc::render_result::wrap ( float  line_width,
float  line_height_multiplier = 1.0f,
fc_alignment  alignment = fc_align_left 
) &
inline

Calls fc_wrap on the vector of character mappings.

The arguments are similar to fc_render_wrapped but calling this is much simpler. It produces the same result. Calling fc::render_result::wrap multiple times produces weird results. Call it only once after fc::font::render.

This is the lvalue version of this function.

Example

fc::font font; // suppose a font that has already been cooked
auto result = font.render("Hello world!");
result.wrap(80.0f);
Parameters
line_widthThe maximum line width, in target/screen size (e.g, pixels)
line_height_multiplierA value that can be used to increase the line height/spacing
alignmentWhich aligment should lines follow
Returns
*this
Examples
main.cpp.

◆ wrap() [2/2]

render_result&& fc::render_result::wrap ( float  line_width,
float  line_height_multiplier = 1.0f,
fc_alignment  alignment = fc_align_left 
) &&
inline

Calls fc_wrap on the vector of character mappings.

The arguments are similar to fc_render_wrapped but calling this is much simpler. It produces the same result. Calling fc::render_result::wrap multiple times produces weird results. Call it only once after fc::font::render.

This is the rvalue version of this function and returns a moveable *this. It is here mainly to assist in method chaining.

Example

fc::font font; // suppose a font that has already been cooked
auto result = font.render("Hello world!").wrap(80.0f);
Parameters
line_widthThe maximum line width, in target/screen size (e.g, pixels)
line_height_multiplierA value that can be used to increase the line height/spacing
alignmentWhich aligment should lines follow
Returns
*this

◆ move() [1/2]

render_result& fc::render_result::move ( float  left = 0.0f,
float  baseline = 0.0f 
) &
inline

This is a wrapper to fc_move. Consult its documentation for more information.

This is the lvalue (non-moveable) version of this function

Example

fc::font font; // suppose a font that has already been cooked
auto result = font.render("Hello world!").move(0.0f, 50.0f);
Parameters
leftLeft position where the text should start rendering
baselineAmount to add to the text baseline
Examples
main.cpp.

◆ move() [2/2]

render_result&& fc::render_result::move ( float  left = 0.0f,
float  baseline = 0.0f 
) &&
inline

This is a wrapper to fc_move. Consult its documentation for more information.

This is the rvalue (moveable) version of this function mainly to be used with method chaining.

Example

fc::font font; // suppose a font that has already been cooked
auto result = font.render("Hello world!").move(0.0f, 50.0f);
Parameters
leftLeft position where the text should start rendering
baselineAmount to add to the text baseline

◆ begin()

std::vector<::fc_character_mapping>::iterator fc::render_result::begin ( )
inline

Returns an iterator pointing to the first character mapping.

Returns
mapping.begin();

◆ end()

std::vector<::fc_character_mapping>::iterator fc::render_result::end ( )
inline

Returns an iterator pointing to the end+1 character mapping.

Returns
mapping.end();

◆ size()

size_t fc::render_result::size ( ) const
inline

Returns the size of the mapping vector (i.e, the number of mappings)

Returns
mapping.size();

The documentation for this struct was generated from the following file:
fc::render_result
Wraps a std::vector<fc_character_mapping>.
Definition: render-result.hpp:29
fc::render_result::wrap
render_result & wrap(float line_width, float line_height_multiplier=1.0f, fc_alignment alignment=fc_align_left) &
Calls fc_wrap on the vector of character mappings.
Definition: render-result.hpp:115
fc::font
A wrapper class for fc_font.
Definition: font.hpp:29
fc::render_result::font
fc_font * font
A pointer to the fc_font used to generate this mapping.
Definition: render-result.hpp:43