Font Chef: Welcome! (original) (raw)

Font Chef is a cross-platform C99 and C++ library to create character atlas of pre-rasterized glyphs from a font at a specified size and color. It is mostly useful in situations where you cannot afford to rasterize a piece of text again whenever it changes.

It abstracts stb_truetype to render glyphs to a pixmap and to produce appropriate clipping rects to later display those glyphs.

Hello world in C++

for (auto & map : result) {

render(texture, map.source, map.target);

}

Hello world in C

fc_add(fc_basic_latin.start, fc_basic_latin.end);

const char hello[] = "Hello, world!";

int count = fc_render(font, text, strlen(hello), output);

for (int i = 0; i < count; i++) {

render(texture, output[i].source, output[i].target

}

Features

Starting points

struct fc_font * fc_construct(uint8_t const *font_data, struct fc_font_size font_size, struct fc_color font_color)

Constructs a fc_font structure with the provided font, a size (either in pixels or points) and a font...

void fc_add(struct fc_font *font, uint32_t first, uint32_t last)

Adds the given unicode range to the list of blocks to be cooked. You must add blocks before calling f...

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

struct fc_render_result fc_render(struct fc_font const *font, unsigned char const *text, size_t byte_count, struct fc_character_mapping *mapping)

Produces a list of source and target rectangles that can be used as clipping rects (or UV maps) for t...