From: hackbard Date: Thu, 13 Sep 2007 11:50:27 +0000 (+0200) Subject: added font2b code to convert linux console fonts to lcd ram layout X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=362d5c63842bf9e3a16de41515f5b76e867d6452;p=my-code%2Farm.git added font2b code to convert linux console fonts to lcd ram layout --- diff --git a/betty/Makefile b/betty/Makefile index cfe49bf..f6d465f 100644 --- a/betty/Makefile +++ b/betty/Makefile @@ -1,6 +1,6 @@ # native builds CC = gcc -CFLAGS = -Wall +CFLAGS = -Wall -I/usr/src/linux/include # cross build ARCH = arm-elf @@ -15,7 +15,7 @@ CROSS_RAM_LDFLAGS = -Tlpc2220_ram.ld -nostartfiles -nostdlib CROSS_ROM_LDFLAGS = -Tlpc2220_rom.ld -nostartfiles -nostdlib # build objects -HOST_TARGET = lpcload fwdump +HOST_TARGET = lpcload fwdump font2b CROSS_TARGET = fwbc.hex fwflash.hex betty.hex # betty deps @@ -25,7 +25,7 @@ BETTY_DEPS = system.o uart.o buttons.o spi.o display.o flash.o functions.o # all projects all: $(HOST_TARGET) $(CROSS_TARGET) -# bmp2b +# bmp2b / font2b links: ln -sfv ../../api/bmp/bmp.{c,h} . 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; +} diff --git a/betty/readme b/betty/readme index c57ba8a..26c715a 100644 --- a/betty/readme +++ b/betty/readme @@ -24,6 +24,10 @@ contents/todo: * bmp2b.c - converts colored bmp images to a format according to the lcd ram (you need my bmb api [my-projects/api]) +* font2b.c - converts linux console fonts (only 8x8!) to the lcd ram format + you need to adjust the source or have the kernel source in + /usr/src/linux. + to be continued ... important: