You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and dots ('.'), can be up to 35 characters long. Letters must be lowercase.
27 lines
739 B
27 lines
739 B
#define STB_TRUETYPE_IMPLEMENTATION |
|
#include "stb_truetype.h" |
|
|
|
#include <stdio.h> |
|
|
|
char ttf_buffer[1<<25]; |
|
|
|
#ifdef TT_TEST |
|
int main(int argc, char **argv) |
|
{ |
|
stbtt_fontinfo font; |
|
unsigned char *bitmap; |
|
int w,h,i,j,c = (argc > 1 ? atoi(argv[1]) : 34807), s = (argc > 2 ? atoi(argv[2]) : 32); |
|
|
|
fread(ttf_buffer, 1, 1<<25, fopen(argc > 3 ? argv[3] : "c:/windows/fonts/mingliu.ttc", "rb")); |
|
|
|
stbtt_InitFont(&font, ttf_buffer, stbtt_GetFontOffsetForIndex(ttf_buffer,0)); |
|
bitmap = stbtt_GetCodepointBitmap(&font, 0,stbtt_ScaleForPixelHeight(&font, (float)s), c, &w, &h, 0,0); |
|
|
|
for (j=0; j < h; ++j) { |
|
for (i=0; i < w; ++i) |
|
putchar(" .:ioVM@"[bitmap[j*w+i]>>5]); |
|
putchar('\n'); |
|
} |
|
return 0; |
|
} |
|
#endif
|
|
|