bdf2sfd

BDF to SFD converter, allowing to vectorize bitmap fonts
Log | Files | Refs | README | LICENSE

commit dea4614c4e10241bcb1a4273a18942efb3428f5d
parent bb359ab2b75434f2cecebabeff6916adb97693a6
Author: Frederic Cambus <fred@statdns.com>
Date:   Sun, 26 Jan 2020 19:50:34 +0100

Compute mask from character weight, instead of hardcoding a value.

Diffstat:
Msrc/bdftosfd.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/bdftosfd.c b/src/bdftosfd.c @@ -114,7 +114,7 @@ main(int argc, char *argv[]) int32_t height = 0, weight = 0; int32_t ascent = 0, descent = 0; - int32_t x = 0, y = 0; + int32_t x = 0, y = 0, mask = 0; struct fontinfo font; memset(&font, 0, sizeof(struct fontinfo)); @@ -165,6 +165,8 @@ main(int argc, char *argv[]) if (errstr) errx(EXIT_FAILURE, "Invalid value for FONTBOUNDINGBOX."); + mask = 1 << (weight - 1); + continue; } @@ -283,7 +285,7 @@ main(int argc, char *argv[]) int32_t row = strtol(lineBuffer, NULL, 16); for (size_t column = 0; column < 8; column++) { - if ((row & (0x80 >> column)) != 0) { + if ((row & (mask >> column)) != 0) { x = column * 64; fprintf(stdout, "%d %d m 25\n", x, y); fprintf(stdout, " %d %d l 25\n", x, y + 64);