Skip to content

Commit

Permalink
Added a simple renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
dhepper committed Feb 12, 2012
1 parent 44c8def commit 55dc0b2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ font8x8_latin.h contains unicode points U+0000 - U+00FF
Author: Daniel Hepper <[email protected]>
License: Public Domain

Renderer
========
To visualize the font, a simple renderer is included in render.c

$ gcc render.c -o render
$ ./render 65
XX
XXXX
XX XX
XX XX
XXXXXX
XX XX
XX XX

Credits
=======
These header files are directly derived from an assembler file fetched from:
Expand Down
38 changes: 38 additions & 0 deletions render.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <stdio.h>

#include "font8x8_basic.h"

void usage(char *exec) {
printf("Usage: %s <char_code>\n", exec);
printf(" <char_code> Decimal character code between 0 and 127\n");
}

void render(char *bitmap) {
int x,y;
int set;
int mask;
for (x=0; x < 8; x++) {
for (y=0; y < 8; y++) {
set = bitmap[x] & 1 << y;
printf("%c", set ? 'X' : ' ');
}
printf("\n");
}
}

int main(int argc, char **argv) {
int ord;
if (argc != 2) {
usage(argv[0]);
return 1;
}
ord = atoi(argv[1]);
if (ord > 127 || ord < 0) {
usage(argv[0]);
return 2;
}
char *bitmap = font8x8_basic[ord];

render(bitmap);
return 0;
}

0 comments on commit 55dc0b2

Please sign in to comment.