Created
September 9, 2016 09:15
-
-
Save danielinux/87f926d0a90bbdae9f0a3a597d5119a4 to your computer and use it in GitHub Desktop.
Font utils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Font to buffers -> convert .font file into C const buffers */ | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <stdlib.h> | |
#include <sys/stat.h> | |
int main(int argc, char *argv[]) | |
{ | |
int i, r, n; | |
unsigned char cc[8]; | |
int fd; | |
if (argc != 2) | |
exit(1); | |
fd = open(argv[1], O_RDONLY); | |
if (fd < 0) | |
exit(2); | |
printf("const unsigned char font[256][8] = {\n", n); | |
i = 0; | |
n = 0; | |
do { | |
r = read(fd, cc, 8); | |
if (r > 0) { | |
printf(" { //Ascii %d\n ", n); | |
for (i = 0; i < 8; i++) | |
printf("0x%02X, ", cc[i]); | |
printf("\n },\n"); | |
} | |
if (++n > 255) | |
break; | |
} while (r > 0); | |
printf("\n};\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment