mirror of
https://gitea.nishi.boats/pyrite-dev/milsko
synced 2026-01-05 09:00:54 +00:00
tools
git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@66 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
61
tools/font.c
Normal file
61
tools/font.c
Normal file
@@ -0,0 +1,61 @@
|
||||
/* $Id$ */
|
||||
#include <ft2build.h>
|
||||
#include FT_FREETYPE_H
|
||||
#include FT_BITMAP_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
FT_Library lib;
|
||||
FT_Face face;
|
||||
int i;
|
||||
int ay = 0;
|
||||
int ax = 0;
|
||||
int sy = 0;
|
||||
int sx = 0;
|
||||
|
||||
FT_Init_FreeType(&lib);
|
||||
if(FT_New_Face(lib, argv[1], 0, &face)) {
|
||||
fprintf(stderr, "bad 1\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(FT_Set_Pixel_Sizes(face, 0, atoi(argv[2]))) {
|
||||
fprintf(stderr, "bad 2\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("/* $Id$ */\n");
|
||||
printf("#include <Mw/Milsko.h>\n");
|
||||
printf("\n");
|
||||
printf("MwFont MwFontData[] = {\n");
|
||||
for(i = 0; i < 0x80; i++) {
|
||||
int y, x;
|
||||
FT_Bitmap bitmap;
|
||||
unsigned char n;
|
||||
if(FT_Load_Char(face, i, FT_LOAD_RENDER | FT_LOAD_COLOR)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
FT_Bitmap_Init(&bitmap);
|
||||
FT_Bitmap_Convert(lib, &face->glyph->bitmap, &bitmap, 1);
|
||||
|
||||
printf("\t{%d, %d, {", face->glyph->bitmap_left, face->glyph->bitmap_top);
|
||||
for(y = 0; y < bitmap.rows; y++) {
|
||||
n = 0;
|
||||
for(x = 0; x < bitmap.width; x++) {
|
||||
unsigned char b = bitmap.buffer[bitmap.width * y + x] ? 1 : 0;
|
||||
n = n << 1;
|
||||
n = n | b;
|
||||
}
|
||||
printf("%d%s", n, y == (bitmap.rows - 1) ? "" : ", ");
|
||||
}
|
||||
printf("}}%s /* %d */\n", i == (0x80 - 1) ? "" : ", ", i);
|
||||
|
||||
FT_Bitmap_Done(lib, &bitmap);
|
||||
|
||||
sx += face->glyph->advance.x >> 6;
|
||||
}
|
||||
printf("};\n");
|
||||
}
|
||||
Reference in New Issue
Block a user