1.1.0
main.cpp

Complete example for the C++ API.

#include "font-chef/font-chef.hpp"
#include "common/font.h"
#include "common/state.hpp"
int main(int argc, char const ** const argv) {
xx::state state;
fc::font font = fc
::from(font_pacifico_ttf.data, fc_pt(30), fc_color_white)
.add(fc_basic_latin)
.cook();
xx::texture font_texture = state.texture(font.pixels());
fc::render_result result = font
.render("Hello, handsome! I mean... world!")
.wrap(state.bounds().right * 0.66f)
.move(0.0f, state.bounds().bottom / 2 - 20);
while (state.update()) {
for (auto & map : result) {
font_texture.render(map.source, map.target);
}
}
return 0;
}
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_pt
struct fc_font_size fc_pt(float value)
Constructs and returns a fc_size value specified as points.
fc::render_result::move
render_result & move(float left=0.0f, float baseline=0.0f) &
This is a wrapper to fc_move. Consult its documentation for more information.
Definition: render-result.hpp:169
fc::font
A wrapper class for fc_font.
Definition: font.hpp:29
fc::font::pixels
fc_pixels pixels() const
Obtains a structure containing a pointer to the pixel data and it's dimensions.
Definition: font.hpp:169
fc_color_white
struct fc_color const fc_color_white
RGBA: #FFFFFFFF
fc::font::cook
font & cook() &
Cooks all the added unicode ranges into a pixmap and clipping information.
Definition: font.hpp:142
fc::from
font from(uint8_t const *font_data, fc::font_size const &font_size, fc::color const &font_color)
A helper method to ease font cooking via method chaining.
Definition: font.hpp:238
fc::font::render
fc::render_result render(std::string const &text) const
Produces clipping and target rectangles to render specified text.
Definition: font.hpp:190
fc::font::add
font & add(fc_unicode_block const &block) &
Adds a new unicode block to be cooked.
Definition: font.hpp:85