X-Git-Url: https://hackdaworld.org/gitweb/?p=my-code%2Farm.git;a=blobdiff_plain;f=betty%2Ffont2b.c;fp=betty%2Ffont2b.c;h=6c1af61adabc0aa2b0a035eae695092f8c7636e5;hp=0000000000000000000000000000000000000000;hb=362d5c63842bf9e3a16de41515f5b76e867d6452;hpb=00632c1df2040d4ee30ff8a9420489f7adfe9963 diff --git a/betty/font2b.c b/betty/font2b.c new file mode 100644 index 0000000..6c1af61 --- /dev/null +++ b/betty/font2b.c @@ -0,0 +1,93 @@ +/* + * font2b.c - convert linux console 8x8 font data to betty lcd ram layout + * + * author: hackbard@hackdaworld.org + * + * usage: + * + * first you have to adjust this file two times (see comments!) + * don't forget to rebuild. + * + * ./font2b > default_font.h + * + * ONLY 8x8 FONTS SUPPORTED! + * + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +// put your font data here! +#include "/usr/src/linux/drivers/video/console/font_pearl_8x8.c" + +#define CHAR 1 +#define BINARY 2 + +int main(int argc,char **argv) { + + unsigned char *font_data; + int font,col,row; + unsigned char buf; + unsigned char stat; + int fd=0; + + // adjust the font data pointer here! + font_data=(unsigned char *)fontdata_pearl8x8; + + stat=CHAR; + if(argc==2) { + fd=open(argv[1],O_WRONLY); + if(fd<0) { + perror("file open"); + return fd; + } + stat=BINARY; + } + + if(stat==CHAR) + printf("const unsigned char default_font[%d]={\n",256*8*2); + + for(font=0;font<=0xff;font++) { + + /* print the font number */ + printf("\t/* %d 0x%02x",font,font); + if((font>0x1f)&(font<0x7f)) + printf(" %c */\n",font); + else + printf(" */\n"); + + /* print the array content of the font */ + for(col=0;col<8;col++) { + buf=0; + for(row=0;row<8;row++) + buf|=(font_data[font*8+row]&(1<<(7-col))); + if(stat==CHAR) { + if(!(col%4)) + printf("\t"); + printf("0x%02x,0x%02x",buf,buf); + if((font!=0xff)|(col!=7)) + printf(","); + if(col==3) + printf("\n"); + } + else { + write(fd,&buf,1); + write(fd,&buf,1); + } + } + if(stat==CHAR) + printf("\n"); + } + + /* end */ + if(stat==CHAR) + printf("};\n"); + else + close(fd); + + return 0; +}