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
- Small, clean and easy-to-use API
- Ships with C++ wrapper classes
- Considers kerning when resolving rendering rects
- Ships with many standard unicode blocks to choose from
- Rendering API agnostic (it does not render anything directly, it returns pixels and clipping rects)
- Fully documented with examples for each function
- No external dependencies
Starting points