1.1.0
Public Member Functions | List of all members
fc::font Class Reference

A wrapper class for fc_font. More...

#include <font.hpp>

Public Member Functions

 font (font &&other) noexcept
 Move constructor. More...
 
 font (font const &other)
 Copy constructor. More...
 
 font (uint8_t const *font_data, fc::font_size const &font_size, fc::color const &font_color)
 Constructs a fc::font instance from a font data, a font size and a font color. More...
 
 ~font ()
 Destructs a fc::font instance and frees all the memory associated with it. More...
 
fontadd (fc_unicode_block const &block) &
 Adds a new unicode block to be cooked. More...
 
font && add (fc_unicode_block const &block) &&
 Adds a new unicode block to be cooked. More...
 
fontadd (uint32_t first, uint32_t last) &
 Adds a new unicode range to be cooked. More...
 
font && add (uint32_t first, uint32_t last) &&
 Adds a new unicode range to be cooked. More...
 
fontcook () &
 Cooks all the added unicode ranges into a pixmap and clipping information. More...
 
font && cook () &&
 Cooks all the added unicode ranges into a pixmap and clipping information. More...
 
fc_pixels pixels () const
 Obtains a structure containing a pointer to the pixel data and it's dimensions. More...
 
fc::render_result render (std::string const &text) const
 Produces clipping and target rectangles to render specified text. More...
 
fc::render_resultrender (std::string const &text, fc::render_result &result) const
 Produces clipping and target rectangles to render specified text reusing an instance of fc::render_result. More...
 

Detailed Description

A wrapper class for fc_font.

You can construct a fc::font yourself or you can use fc::from (which is preferred if you are going to use method chaining, see fc::from for an examples).

Examples
main.cpp.

Constructor & Destructor Documentation

◆ font() [1/3]

fc::font::font ( font &&  other)
inlinenoexcept

Move constructor.

Parameters
otherThe other fc::font instance to move from.

◆ font() [2/3]

fc::font::font ( font const &  other)
inline

Copy constructor.

Warning
It does not actually copy anything. It reconstructs another fc::font instance with the same steps used to construct the other.
Parameters
otherThe other fc::font instance to copy from

◆ font() [3/3]

fc::font::font ( uint8_t const *  font_data,
fc::font_size const &  font_size,
fc::color const &  font_color 
)
inline

Constructs a fc::font instance from a font data, a font size and a font color.

Parameters
font_dataThe font data in memory
font_sizeThe size of the font, either in fc::px or fc::pt
font_colorThe color of the font
See also
fc_construct

◆ ~font()

fc::font::~font ( )
inline

Destructs a fc::font instance and frees all the memory associated with it.

See also
fc_destruct

Member Function Documentation

◆ add() [1/4]

font& fc::font::add ( fc_unicode_block const &  block) &
inline

Adds a new unicode block to be cooked.

This is the lvalue version of this method (objects with a name)

Parameters
blockThe block to be cooked
Returns
*this
See also
fc_add
Examples
main.cpp.

◆ add() [2/4]

font&& fc::font::add ( fc_unicode_block const &  block) &&
inline

Adds a new unicode block to be cooked.

This is the rvalue version of this method (objects without a name)

Parameters
blockThe block to be cooked
Returns
*this
See also
fc_add

◆ add() [3/4]

font& fc::font::add ( uint32_t  first,
uint32_t  last 
) &
inline

Adds a new unicode range to be cooked.

This is the lvalue version of this method (objects with a name)

Parameters
firstThe first unicode point in the range
lastThe last unicode point in the range
Returns
*this
See also
fc_add

◆ add() [4/4]

font&& fc::font::add ( uint32_t  first,
uint32_t  last 
) &&
inline

Adds a new unicode range to be cooked.

This is the rvalue version of this method (objects without a name)

Parameters
firstThe first unicode point in the range
lastThe last unicode point in the range
Returns
*this
See also
fc_add

◆ cook() [1/2]

font& fc::font::cook ( ) &
inline

Cooks all the added unicode ranges into a pixmap and clipping information.

This is the lvalue version of this method (objects with a name)

Returns
*this
See also
fc_cook
Examples
main.cpp.

◆ cook() [2/2]

font&& fc::font::cook ( ) &&
inline

Cooks all the added unicode ranges into a pixmap and clipping information.

This is the rvalue version of this method (objects without a name)

Returns
*this
See also
fc_cook

◆ pixels()

fc_pixels fc::font::pixels ( ) const
inline

Obtains a structure containing a pointer to the pixel data and it's dimensions.

Use this function when you want to create a texture after cooking the font with the desired unicode blocks/ranges

Returns
a fc_pixels value
Examples
main.cpp.

◆ render() [1/2]

fc::render_result fc::font::render ( std::string const &  text) const
inline

Produces clipping and target rectangles to render specified text.

This is equivalent to calling fc_render but a lot easier. It returns an instance of fc::render_result that contains the character mapping vector.

Example

fc::font font; // suppose a font that has already been cooked
fc::render_result result = font.render("Hello world!");
Parameters
textThe text to render
Returns
An instance of fc::render_result
See also
fc_render
fc::render_result
Examples
main.cpp.

◆ render() [2/2]

fc::render_result& fc::font::render ( std::string const &  text,
fc::render_result result 
) const
inline

Produces clipping and target rectangles to render specified text reusing an instance of fc::render_result.

You can use this function if you already have an instance of fc::render_result and want to reuse it without allocating a new one. The vector will be reallocated if needed.

Parameters
textThe text to render
resultThe fc::render_result instance to reuse
Returns
The same fc::render_result reference passed in result argument.
See also
fc_render
fc::render_result
fc::font::render

The documentation for this class was generated from the following file:
fc::render_result
Wraps a std::vector<fc_character_mapping>.
Definition: render-result.hpp:29
fc::font
A wrapper class for fc_font.
Definition: font.hpp:29
fc::font::font
font(font &&other) noexcept
Move constructor.
Definition: font.hpp:38