Module Name:    xsrc
Committed By:   macallan
Date:           Tue Aug 23 19:09:15 UTC 2022

Modified Files:
        xsrc/local/programs/bdfload: bdfload.c

Log Message:
limit the comment width in the header output to the size of the character cell


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 xsrc/local/programs/bdfload/bdfload.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: xsrc/local/programs/bdfload/bdfload.c
diff -u xsrc/local/programs/bdfload/bdfload.c:1.10 xsrc/local/programs/bdfload/bdfload.c:1.11
--- xsrc/local/programs/bdfload/bdfload.c:1.10	Tue Aug 23 18:28:14 2022
+++ xsrc/local/programs/bdfload/bdfload.c	Tue Aug 23 19:09:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bdfload.c,v 1.10 2022/08/23 18:28:14 macallan Exp $	*/
+/*	$NetBSD: bdfload.c,v 1.11 2022/08/23 19:09:15 macallan Exp $	*/
 
 /*
  * Copyright (c) 2018 Michael Lorenz
@@ -160,7 +160,7 @@ write_header(const char *filename, struc
              char *buffer, int buflen)
 {
 	FILE *output;
-	int i, j, x, y, idx;
+	int i, j, x, y, idx, pxls, left;
 	char fontname[64], c, msk;
 	
 	/* now output as a header file */
@@ -203,14 +203,17 @@ write_header(const char *filename, struc
 				fprintf(output, "0x%02x, ",buffer[idx + x]);
 			}
 			fprintf(output, "/* ");
+			pxls = f->fontwidth;
 			for (x = 0; x < f->stride; x++) {
 				c = buffer[idx + x];
 				msk = 0x80;
-				for (j = 0; j < 8; j++) {
+				left = pxls > 8 ? 8 : pxls;
+				for (j = 0; j < left; j++) {
 					fprintf(output, "%s",
 					    (c & msk) != 0 ? "[]" : ". ");
 					msk = msk >> 1;
 				}
+				pxls -= 8;
 			}
 			fprintf(output, " */\n");
 

Reply via email to