diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-08-08 09:16:31 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-08-08 09:16:31 (GMT) |
| commit | 11d3cb0dd56ddc7df49570e41c3f8f9f01d872d1 (patch) | |
| tree | 204ada574a8dcd2aedf4d9319120af3e5e82ea41 | |
| parent | 6dedc285170d286b61c41558c6c0b187747e97ec (diff) | |
| download | powder-11d3cb0dd56ddc7df49570e41c3f8f9f01d872d1.zip powder-11d3cb0dd56ddc7df49570e41c3f8f9f01d872d1.tar.gz | |
Update font editor
| -rw-r--r-- | font/Makefile | 6 | ||||
| -rw-r--r-- | font/font.bin | bin | 30980 -> 30980 bytes | |||
| -rw-r--r-- | font/unpacker.c | 107 |
3 files changed, 113 insertions, 0 deletions
diff --git a/font/Makefile b/font/Makefile index 7bb04e0..70f1ff8 100644 --- a/font/Makefile +++ b/font/Makefile @@ -1,5 +1,11 @@ editor: editor.c gcc -oeditor -DSCALE=2 -DFONTEDITOR editor.c -lSDL -lm -O3 -ffast-math -march=k8 -Wall -std=c99 + +packer: packer.c + gcc -opacker -DFONTEDITOR editor.c -lSDL -lm -O3 -ffast-math -march=k8 -Wall -std=c99 + +unpacker: unpacker.c + gcc -ounpacker -DFONTEDITOR editor.c -lSDL -lm -O3 -ffast-math -march=k8 -Wall -std=c99 clean: rm -f editor packer diff --git a/font/font.bin b/font/font.bin Binary files differindex b81615a..3eabed0 100644 --- a/font/font.bin +++ b/font/font.bin diff --git a/font/unpacker.c b/font/unpacker.c new file mode 100644 index 0000000..a2a4cc6 --- /dev/null +++ b/font/unpacker.c @@ -0,0 +1,107 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include "font.h" + +#define CELLW 12 +#define CELLH 10 + +char xsize=CELLW, ysize=CELLH; +char base=7, top=2; +char font[256][CELLH][CELLW]; +char width[256]; + +int bits_n = 0, bits_a = 0; +int flush_bits(void) +{ + if(bits_n) { + bits_a >>= 8-bits_n; + printf("0x%02X, ", bits_a); + bits_a = 0; + bits_n = 0; + return 1; + } + return 0; +} +int stock_bits(int b, int nb) +{ + bits_a >>= nb; + bits_a |= b << (8-nb); + bits_n += nb; + if(bits_n >= 8) { + printf("0x%02X, ", bits_a); + bits_a = 0; + bits_n = 0; + return 1; + } + return 0; +} + +int save_char(int c) +{ + int nb = 1; + int x, y; + + if(!width[c]) + return 0; + + printf(" 0x%02X, ", width[c]); + + for(y=0; y<CELLH; y++) + for(x=0; x<width[c]; x++) + nb += stock_bits(font[c][y][x]&3, 2); + nb += flush_bits(); + + printf("\n"); + + return nb; +} + +void load_char(int c) +{ + unsigned char *start = font_data + font_ptrs[c]; + int x, y, w, b; + + w = *(start ++); + + if(!w) + return; + + b = 0; + for(y=0; y<CELLH; y++) + for(x=0; x<w; x++) { + font[c][y][x] = ((*start) >> b) & 3; + b += 2; + if(b >= 8) { + start ++; + b = 0; + } + } + + width[c] = w; +printf("%02x: %d\n", c, w); +} + +char *tag = "(c) 2011 Stanislaw Skowronek"; + +int main(int argc, char *argv[]) +{ + FILE *f; + int i; + + for(i=0; i<sizeof(font_ptrs)/sizeof(short); i++) + load_char(i); + + f = fopen("font.bin", "w"); + fwrite(&xsize, 1, 1, f); + fwrite(&ysize, 1, 1, f); + fwrite(&base, 1, 1, f); + fwrite(&top, 1, 1, f); + fwrite(width, 1, 256, f); + fwrite(font, CELLW*CELLH, 256, f); + fclose(f); + + return 0; +}
\ No newline at end of file |
