Module Name: src
Committed By: macallan
Date: Fri Jun 23 02:16:39 UTC 2017
Modified Files:
src/usr.sbin/wsfontload: wsfontload.c
Log Message:
load files from ttf2wsfont
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/wsfontload/wsfontload.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/wsfontload/wsfontload.c
diff -u src/usr.sbin/wsfontload/wsfontload.c:1.18 src/usr.sbin/wsfontload/wsfontload.c:1.19
--- src/usr.sbin/wsfontload/wsfontload.c:1.18 Fri Apr 5 03:18:26 2013
+++ src/usr.sbin/wsfontload/wsfontload.c Fri Jun 23 02:16:39 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: wsfontload.c,v 1.18 2013/04/05 03:18:26 dholland Exp $ */
+/* $NetBSD: wsfontload.c,v 1.19 2017/06/23 02:16:39 macallan Exp $ */
/*
* Copyright (c) 1999
@@ -33,6 +33,7 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/ioctl.h>
+#include <sys/stat.h>
#include <err.h>
#include <dev/wscons/wsconsio.h>
@@ -134,9 +135,11 @@ main(int argc, char **argv)
{
const char *wsdev;
struct wsdisplay_font f;
+ struct stat st;
int c, res, wsfd, ffd, verbose = 0;
size_t len;
void *buf;
+ char nbuf[65];
wsdev = DEFDEV;
f.fontwidth = DEFWIDTH;
@@ -205,6 +208,39 @@ main(int argc, char **argv)
if (!f.stride)
f.stride = (f.fontwidth + 7) / 8;
len = f.fontheight * f.numchars * f.stride;
+ if (fstat(ffd, &st) == 0) {
+ if (len != st.st_size) {
+ uint32_t foo = 0;
+ char b[65];
+ len = st.st_size;
+ /* read header */
+ read(ffd, b, 4);
+ if (strncmp(b, "WSFT", 4) != 0)
+ errx(1, "invalid wsf file ");
+ read(ffd, b, 64);
+ b[64] = 0;
+ strcpy(nbuf, b);
+ f.name = nbuf;
+ read(ffd, &foo, 4);
+ f.firstchar = le32toh(foo);
+ read(ffd, &foo, 4);
+ f.numchars = le32toh(foo);
+ read(ffd, &foo, 4);
+ f.encoding = le32toh(foo);
+ read(ffd, &foo, 4);
+ f.fontwidth = le32toh(foo);
+ read(ffd, &foo, 4);
+ f.fontheight = le32toh(foo);
+ read(ffd, &foo, 4);
+ f.stride = le32toh(foo);
+ read(ffd, &foo, 4);
+ f.bitorder = le32toh(foo);
+ read(ffd, &foo, 4);
+ f.byteorder = le32toh(foo);
+ len = f.numchars * f.fontheight * f.stride;
+ }
+ }
+
if (!len)
errx(1, "invalid font size");