]> hackdaworld.org Git - my-code/arm.git/commitdiff
added font2b code to convert linux console fonts to lcd ram layout
authorhackbard <hackbard@sage.physik.uni-augsburg.de>
Thu, 13 Sep 2007 11:50:27 +0000 (13:50 +0200)
committerhackbard <hackbard@sage.physik.uni-augsburg.de>
Thu, 13 Sep 2007 11:50:27 +0000 (13:50 +0200)
betty/Makefile
betty/font2b.c [new file with mode: 0644]
betty/readme

index cfe49bf0d1762729c7c232da634c0fdd2b131b82..f6d465f5a703741b2cebbacee878245437ee4ee3 100644 (file)
@@ -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 (file)
index 0000000..6c1af61
--- /dev/null
@@ -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 <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+// 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;
+}
index c57ba8a892e742b75c7f5295ba0d84af8dc10593..26c715aba7d0af19321c47e9781a2d498d7458b9 100644 (file)
@@ -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: