From 8d951aca167acced4975d0b7bcb82fe029038fdf Mon Sep 17 00:00:00 2001 From: emaste Date: Tue, 3 Apr 2018 18:43:00 +0000 Subject: [PATCH] vtfontcvt: allow .bdf characters less than full height Sponsored by: The FreeBSD Foundation --- usr.bin/vtfontcvt/vtfontcvt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/usr.bin/vtfontcvt/vtfontcvt.c b/usr.bin/vtfontcvt/vtfontcvt.c index 5e1cc531e058..73b433c329f9 100644 --- a/usr.bin/vtfontcvt/vtfontcvt.c +++ b/usr.bin/vtfontcvt/vtfontcvt.c @@ -265,10 +265,23 @@ parse_bdf(FILE *fp, unsigned int map_idx) if (strncmp(ln, "BITMAP", 6) == 0 && (ln[6] == ' ' || ln[6] == '\0')) { + /* + * Assume that the next _height_ lines are bitmap + * data. ENDCHAR is allowed to terminate the bitmap + * early but is not otherwise checked; any extra data + * is ignored. + */ for (i = 0; i < height; i++) { if ((ln = fgetln(fp, &length)) == NULL) errx(1, "Unexpected EOF!"); ln[length - 1] = '\0'; + if (strcmp(ln, "ENDCHAR") == 0) { + memset(bytes + i * wbytes, 0, + (height - i) * wbytes); + memset(bytes_r + i * wbytes, 0, + (height - i) * wbytes); + break; + } sscanf(ln, "%x", &line); if (parse_bitmap_line(bytes + i * wbytes, bytes_r + i * wbytes, line, dwidth) != 0)