summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/wsfontload/Makefile8
-rw-r--r--usr.sbin/wsfontload/wsfontload.8116
-rw-r--r--usr.sbin/wsfontload/wsfontload.c187
3 files changed, 311 insertions, 0 deletions
diff --git a/usr.sbin/wsfontload/Makefile b/usr.sbin/wsfontload/Makefile
new file mode 100644
index 00000000000..57610c8cba3
--- /dev/null
+++ b/usr.sbin/wsfontload/Makefile
@@ -0,0 +1,8 @@
+# $OpenBSD: Makefile,v 1.1 2000/07/02 01:29:44 mickey Exp $
+# $NetBSD: Makefile,v 1.1 1999/01/13 17:15:44 drochner Exp $
+
+PROG= wsfontload
+MAN= wsfontload.8
+SRCS= wsfontload.c
+
+.include <bsd.prog.mk>
diff --git a/usr.sbin/wsfontload/wsfontload.8 b/usr.sbin/wsfontload/wsfontload.8
new file mode 100644
index 00000000000..1f9c154bb2d
--- /dev/null
+++ b/usr.sbin/wsfontload/wsfontload.8
@@ -0,0 +1,116 @@
+.\" $OpenBSD: wsfontload.8,v 1.1 2000/07/02 01:29:44 mickey Exp $
+.\" $NetBSD: wsfontload.8,v 1.5 1999/04/06 04:54:22 cgd Exp $
+.\"
+.Dd January 13, 1999
+.Os
+.Dt WSFONTLOAD 8
+.Sh NAME
+.Nm wsfontload
+.Nd load a font bitmap into a wscons display device
+.Sh SYNOPSIS
+.Nm ""
+.Bk -words
+.Op Fl f Ar ctldev
+.Ek
+.Bk -words
+.Op Fl w Ar width
+.Ek
+.Bk -words
+.Op Fl h Ar height
+.Ek
+.Bk -words
+.Op Fl e Ar encoding
+.Ek
+.Bk -words
+.Op Fl N Ar name
+.Ek
+.Bk -words
+.Op Fl b
+.Ek
+.Bk -words
+.Op Fl B
+.Ek
+.Op Ar fontfile
+.Sh DESCRIPTION
+The
+.Nm
+utility loads a font bitmap to a wscons device if the device driver
+supports this.
+The font gets assigned a name in this process which it can be referred to
+by later for use on a display screen.
+The font is loaded from the specified
+.Ar fontfile ,
+or from
+.Pa stdin
+if
+.Ar fontfile
+is not provided.
+.Pp
+The options are:
+.Bl -tag -width xxxxxxxxxxx
+.It Fl f Ar ctldev
+Specify the control device of the wscons display to operate on.
+Default is
+.Pa /dev/ttyEcfg .
+.It Fl w Ar width
+Sets the width of a font character in pixels. Default is 8.
+.It Fl h Ar height
+Sets the width of a font character in pixels. Default is 16.
+.It Fl e Ar encoding
+Sets the encoding of the font. This can be either a symbolic abbreviation
+or a numeric value. Currently recognized abbreviations are
+.Dq iso
+for ISO-8859-1 encoding,
+.Dq ibm
+for IBM encoded fonts and
+.Dq pcvt
+for the custom encoding of the supplemental fonts which came with
+the BSD
+.Dq pcvt
+console driver. Per default,
+.Dq iso
+is assumed.
+.It Fl N Ar name
+Specifies a name which can be used later to refer to the font.
+In none is given, the
+.Ar fontfile
+name is used to create one.
+.It Fl b
+Specifies that the font data is ordered right-to-left bit wise. The default
+is left-to-right.
+.It Fl B
+Specifies that the font data is ordered right-to-left byte wise. The default
+is left-to-right.
+.El
+.Pp
+Typically, the
+.Nm
+utility will be executed in system startup by the
+.Pa /etc/rc.wscons
+script, controlled by the
+.Pa /etc/wscons.conf
+configuration file.
+.Pp
+No font files are provided with the wscons framework. The fonts installed by
+.Xr pcvt 4
+can be used instead, as can raw font files from other operating system
+distributions.
+.Sh FILES
+.Pa /etc/wscons.conf
+.Sh EXAMPLES
+.Dl wsfontload -N myname -h 8 -e ibm /usr/share/pcvt/fonts/vt220l.808
+.Pp
+Load the IBM-encoded 8x8-font from the
+.Xr pcvt 4
+distribution. This (or another 8x8-font) is necessary to use the
+50-line screen type on
+.Xr vga 4
+displays.
+.Sh BUGS
+Many features are missing.
+.Pp
+There is no way ro remove a loaded font.
+.Sh SEE ALSO
+.Xr wscons 4 ,
+.Xr wsconscfg 8 ,
+.Xr wsconsctl 8
diff --git a/usr.sbin/wsfontload/wsfontload.c b/usr.sbin/wsfontload/wsfontload.c
new file mode 100644
index 00000000000..1104e05d8a2
--- /dev/null
+++ b/usr.sbin/wsfontload/wsfontload.c
@@ -0,0 +1,187 @@
+/* $OpenBSD: wsfontload.c,v 1.1 2000/07/02 01:29:44 mickey Exp $ */
+/* $NetBSD: wsfontload.c,v 1.2 2000/01/05 18:46:43 ad Exp $ */
+
+/*
+ * Copyright (c) 1999
+ * Matthias Drochner. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Matthias Drochner.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <err.h>
+
+#include <dev/wscons/wsconsio.h>
+
+#define DEFDEV "/dev/ttyEcfg"
+#define DEFWIDTH 8
+#define DEFHEIGHT 16
+#define DEFENC WSDISPLAY_FONTENC_ISO
+#define DEFBITORDER WSDISPLAY_FONTORDER_L2R
+#define DEFBYTEORDER WSDISPLAY_FONTORDER_L2R
+
+int main __P((int, char**));
+static void usage __P((void));
+static int getencoding __P((char *));
+
+static void
+usage()
+{
+ extern char *__progname;
+
+ (void)fprintf(stderr,
+ "Usage: %s [-f wsdev] [-w width] [-h height] [-e encoding]"
+ " [-N name] [-b] [-B] [fontfile]\n",
+ __progname);
+ exit(1);
+}
+
+int
+main(argc, argv)
+ int argc;
+ char **argv;
+{
+ char *wsdev;
+ struct wsdisplay_font f;
+ int c, res, wsfd, ffd;
+ size_t len;
+ void *buf;
+
+ wsdev = DEFDEV;
+ f.fontwidth = DEFWIDTH;
+ f.fontheight = DEFHEIGHT;
+ f.firstchar = 0;
+ f.numchars = 256;
+ f.stride = 0;
+ f.encoding = DEFENC;
+ f.name = 0;
+ f.bitorder = DEFBITORDER;
+ f.byteorder = DEFBYTEORDER;
+
+ while ((c = getopt(argc, argv, "f:w:h:e:N:bB")) != -1) {
+ switch (c) {
+ case 'f':
+ wsdev = optarg;
+ break;
+ case 'w':
+ if (sscanf(optarg, "%d", &f.fontwidth) != 1)
+ errx(1, "invalid font width");
+ break;
+ case 'h':
+ if (sscanf(optarg, "%d", &f.fontheight) != 1)
+ errx(1, "invalid font height");
+ break;
+ case 'e':
+ f.encoding = getencoding(optarg);
+ break;
+ case 'N':
+ f.name = optarg;
+ break;
+ case 'b':
+ f.bitorder = WSDISPLAY_FONTORDER_R2L;
+ break;
+ case 'B':
+ f.byteorder = WSDISPLAY_FONTORDER_R2L;
+ break;
+ case '?':
+ default:
+ usage();
+ break;
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc > 1)
+ usage();
+
+ wsfd = open(wsdev, O_RDWR, 0);
+ if (wsfd < 0)
+ err(2, "open ws");
+
+ if (argc > 0) {
+ ffd = open(argv[0], O_RDONLY, 0);
+ if (ffd < 0)
+ err(4, "open font");
+ if (!f.name)
+ f.name = argv[0];
+ } else
+ ffd = 0;
+
+ if (!f.stride)
+ f.stride = (f.fontwidth + 7) / 8;
+ len = f.fontheight * f.numchars * f.stride;
+ if (!len)
+ errx(1, "invalid font size");
+
+ buf = malloc(len);
+ if (!buf)
+ errx(1, "malloc");
+ res = read(ffd, buf, len);
+ if (res < 0)
+ err(4, "read font");
+ if (res != len)
+ errx(4, "short read");
+
+ f.data = buf;
+
+ res = ioctl(wsfd, WSDISPLAYIO_LDFONT, &f);
+ if (res < 0)
+ err(3, "WSDISPLAYIO_LDFONT");
+
+ return (0);
+}
+
+static struct {
+ char *name;
+ int val;
+} encodings[] = {
+ {"iso", WSDISPLAY_FONTENC_ISO},
+ {"ibm", WSDISPLAY_FONTENC_IBM},
+ {"pcvt", WSDISPLAY_FONTENC_PCVT},
+};
+
+static int
+getencoding(name)
+ char *name;
+{
+ int i;
+
+ for (i = 0; i < sizeof(encodings) / sizeof(encodings[0]); i++)
+ if (!strcmp(name, encodings[i].name))
+ return (encodings[i].val);
+
+ if (sscanf(name, "%d", &i) != 1)
+ errx(1, "invalid encoding");
+ return (i);
+}