#define STB_TRUETYPE_IMPLEMENTATION #define STBTT_STATIC #include "third-party/stb_truetype.h" #include #ifndef CODEPOINT #define CODEPOINT 65 #endif #define SIZE (1 << 25) static unsigned char ttf_buffer[SIZE]; int main() { FILE* f; const float font_size = 42.5; stbtt_fontinfo info; f = fopen("fonts/FiraSans-Regular.otf", "rb"); int x = fread(ttf_buffer, 1, SIZE, f); fclose(f); stbtt_InitFont(&info, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer, 0)); int width; int height; int xoff; int yoff; unsigned char* data = stbtt_GetGlyphSDF( &info, stbtt_ScaleForPixelHeight(&info, font_size), stbtt_FindGlyphIndex(&info, CODEPOINT), 3, 128, 255/6, &width, &height, &xoff, &yoff ); f = fopen("build/illustration-stb.txt", "w"); fprintf(f, "%d %d %d %d\n", width, height, xoff, yoff); fclose(f); f = fopen("build/illustration-stb.bin", "wb"); fwrite(data, 1, width*height, f); fclose(f); }