Convert BDF bitmap fonts to flf fonts for figlet
git clone https://github.com/m-col/bdf2flf
Files | Refs | Readme

Commit c70a21514c3464c9e0bdd2ef411086c546a9ef9d
Parent: cba8f74bc5ce7dd3c01e6514483b7e4bf361f490
Author: mcol <mcol@posteo.net>
Date: 2020-10-27 14:07:23 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2020-10-27 14:07:23 +0000

malloc enough bytes for all bdf font sizes

bdf2flf.c Modified

@@ -132,7 +132,8 @@
 	die("Could not allocate memory.\n");
 
     // extract individual char data
-    for (;;) { if (!fgets(linebuf, sizeof(linebuf), in))
+    for (;;) {
+	if (!fgets(linebuf, sizeof(linebuf), in))
 	    break;
 	if (!(s = strtok(linebuf, " \t\n\r")))
 	    continue;
@@ -145,7 +146,7 @@
 		die("bdf font has incorrect CHARS value.\n");
 	    i = 0;
 	    chars[n].printed = 0;
-	    chars[n].bitmap = malloc(1);
+	    chars[n].bitmap = malloc((width + 7) / 8 * height * 2);
 	    chars[n].bitmap[0] = '\0';
 	    for (;;) {
 		fgets(linebuf, sizeof(linebuf), in);
@@ -204,7 +205,7 @@
 		" and figlet font data is output to stdout.\n");
 	exit(EXIT_SUCCESS);
     }
-    
+
     bdf2flf(stdin, stdout);
 
     (void)(argv);  // shush the compiler