Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[xsrc/trunk]: xsrc/local/programs/bdfload add -d option to dump rendered char...
details: https://anonhg.NetBSD.org/xsrc/rev/8fcc2a23447a
branches: trunk
changeset: 7132:8fcc2a23447a
user: macallan <macallan%NetBSD.org@localhost>
date: Tue Aug 16 21:28:53 2022 +0000
description:
add -d option to dump rendered characters to the console
diffstat:
local/programs/bdfload/bdfload.c | 35 ++++++++++++++++++++++++++++++++---
1 files changed, 32 insertions(+), 3 deletions(-)
diffs (93 lines):
diff -r ed3b1c32d830 -r 8fcc2a23447a local/programs/bdfload/bdfload.c
--- a/local/programs/bdfload/bdfload.c Tue Aug 16 20:27:33 2022 +0000
+++ b/local/programs/bdfload/bdfload.c Tue Aug 16 21:28:53 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bdfload.c,v 1.4 2022/08/16 20:27:33 macallan Exp $ */
+/* $NetBSD: bdfload.c,v 1.5 2022/08/16 21:28:53 macallan Exp $ */
/*
* Copyright (c) 2018 Michael Lorenz
@@ -98,8 +98,24 @@
const char *ofile = NULL;
int encoding = -1;
int verbose = 0;
+int dump = 0;
+void
+dump_line(char *gptr, int stride)
+{
+ int i, j, msk, c;
+ for (i = 0; i < stride; i++) {
+ c = gptr[i];
+ msk = 0x80;
+ for (j = 0; j < 8; j++) {
+ putchar((c & msk) != 0 ? '#' : ' ');
+ msk = msk >> 1;
+ }
+ printf("\n");
+ }
+}
+
void
interpret(FILE *foo)
{
@@ -164,6 +180,7 @@
if (current >= 0 && current < 256) {
if (current < first) first = current;
if (current > last) last = current;
+ if (dump) printf("glyph %d\n", current);
}
}
} else if (strcmp(line, "BBX") == 0) {
@@ -177,6 +194,7 @@
if (top < bt) bt = top;
if ((left + cwi) > br) br = left + cwi;
if ((top + che) > bb) bb = top + che;
+ if(dump && verbose) printf("top %d left %d\n", top, left);
}
} else if (strcmp(line, "BITMAP") == 0) {
int i, j, k, l;
@@ -202,6 +220,13 @@
bptr16++;
}
}
+ if (dump) {
+ gptr = &buffer[charsize * current];
+ for (i = 0; i < height; i++) {
+ dump_line(gptr, stride);
+ gptr += stride;
+ }
+ }
}
}
if (verbose) {
@@ -270,7 +295,7 @@
__dead void
usage()
{
- fprintf(stderr, "usage: bdfload [-v] [-e encoding] [-o ofile.wsf] font.bdf\n");
+ fprintf(stderr, "usage: bdfload [-vd] [-e encoding] [-o ofile.wsf] font.bdf\n");
exit(EXIT_FAILURE);
}
@@ -281,7 +306,7 @@
const char *encname = NULL;
int c;
- while ((c = getopt(argc, argv, "e:o:v")) != -1) {
+ while ((c = getopt(argc, argv, "e:o:vd")) != -1) {
switch (c) {
/* font encoding */
@@ -302,6 +327,10 @@
verbose = 1;
break;
+ case 'd':
+ dump = 1;
+ break;
+
case '?': /* FALLTHROUGH */
default:
usage();
Home |
Main Index |
Thread Index |
Old Index