Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/wsfontload load files from ttf2wsfont



details:   https://anonhg.NetBSD.org/src/rev/5bed3e4e155b
branches:  trunk
changeset: 824938:5bed3e4e155b
user:      macallan <macallan%NetBSD.org@localhost>
date:      Fri Jun 23 02:16:39 2017 +0000

description:
load files from ttf2wsfont

diffstat:

 usr.sbin/wsfontload/wsfontload.c |  38 +++++++++++++++++++++++++++++++++++++-
 1 files changed, 37 insertions(+), 1 deletions(-)

diffs (69 lines):

diff -r e94ecddfd1c6 -r 5bed3e4e155b usr.sbin/wsfontload/wsfontload.c
--- a/usr.sbin/wsfontload/wsfontload.c  Fri Jun 23 01:57:40 2017 +0000
+++ b/usr.sbin/wsfontload/wsfontload.c  Fri Jun 23 02:16:39 2017 +0000
@@ -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 @@
 {
        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 @@
        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");
 



Home | Main Index | Thread Index | Old Index