Date: Fri, 9 Jul 1999 01:41:56 +0100 From: Ben Smithurst <ben@scientia.demon.co.uk> To: Mark Ovens <markov@globalnet.co.uk> Cc: Evren Yurtesen <yurtesen@ispro.net.tr>, freebsd-questions@freebsd.org Subject: Re: how to create a font ? Message-ID: <19990709014156.A49065@rainbow5.scientia.demon.co.uk> In-Reply-To: <19990709013048.B254@marder-1> References: <3783A62B.6976A379@ispro.net.tr> <19990707233530.A42991@rainbow5.scientia.demon.co.uk> <19990709013048.B254@marder-1>
next in thread | previous in thread | raw e-mail | index | archive | help
--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Mark Ovens wrote:
> Are fontdump & fontmake the "*very* rough programs" that you're
> talking about? If so, where are they available from?
Self-LART for me there, I meant to attach them. They're here this time,
honest.
--
Ben Smithurst | PGP: 0x99392F7D
ben@scientia.demon.co.uk | key available from keyservers and
| ben+pgp@scientia.demon.co.uk
--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="fontdump.c"
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void usage();
void font_dump(FILE *, int);
int
main(int argc, char **argv) {
FILE *fp;
struct stat sb;
int size;
if (getopt(argc, argv, "") != -1)
usage();
argc -= optind;
argv += optind;
if (argc != 1)
usage();
if ((fp = fopen(*argv, "r")) == NULL)
err(1, "%s", *argv);
if (fstat(fileno(fp), &sb) < 0)
err(1, "fstat");
if (sb.st_size == 16 * 256)
size = 16;
else if (sb.st_size == 14 * 256)
size = 14;
else if (sb.st_size == 8 * 256)
size = 8;
else
errx(1, "unknown font size");
font_dump(fp, size);
return (0);
}
void
font_dump(FILE *fp, int size) {
int ch, li, d, bit;
for (ch = 0; ch < 256; ch++) {
printf("- %c ----\n", isprint(ch) ? ch : ' ');
for (li = 0; li < size; li++) {
d = getc(fp);
if (d == EOF)
errx(1, "unexpected EOF");
for (bit = 7; bit >= 0; bit--)
if (d & (1 << bit))
printf("#");
else
printf(" ");
printf("\n");
}
printf("--------\n");
}
}
void
usage() {
fprintf(stderr, "usage: fontedit font\n");
exit(1);
}
--jRHKVT23PllUwdXP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="fontmake.c"
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
void usage();
void font_make(FILE *);
int
main(int argc, char **argv) {
FILE *fp;
if (getopt(argc, argv, "") != -1)
usage();
argc -= optind;
argv += optind;
if (argc != 1)
usage();
if ((fp = fopen(*argv, "r")) == NULL)
err(1, "%s", *argv);
font_make(fp);
return (0);
}
void
font_make(FILE *fp) {
char line[20];
int byte, bit, size;
size = 0;
while (fgets(line, sizeof line, fp) != NULL) {
if (strlen(line) > 4 && strcmp(line + 4, "----\n") == 0) {
if (size != 0 && size != 8 &&
size != 14 && size != 16)
errx(1, "bad file format, wrong size");
else {
size = 0;
continue;
}
}
size++;
byte = 0;
for (bit = 0; bit < 8; bit++)
if (line[bit] == '\n')
/* end of line, assume all spaces */
break;
else if (line[bit] == '#')
byte |= 1 << (7 - bit);
else if (line[bit] != ' ')
errx(1, "bad file format, "
"bad character %c (%x)",
line[bit], line[bit]);
putc(byte, stdout);
}
if (size != 0 && size != 8 && size != 14 && size != 16)
errx(1, "bad file format, wrong size %d (at end)", size);
}
void
usage() {
fprintf(stderr, "usage: fontedit font\n");
exit(1);
}
--jRHKVT23PllUwdXP--
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990709014156.A49065>
