summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfcambus <fcambus@openbsd.org>2020-08-05 13:56:06 +0000
committerfcambus <fcambus@openbsd.org>2020-08-05 13:56:06 +0000
commit442ef12c5cd5d8de0ade0c1d27d834ce9816d23e (patch)
tree9a50ec1118829e010163620ee2c0ea21b7d64ab8
parentAllow the WSDISPLAYIO_GETSCREENTYPE ioctl on the tty*cfg device, passing (diff)
downloadwireguard-openbsd-442ef12c5cd5d8de0ade0c1d27d834ce9816d23e.tar.xz
wireguard-openbsd-442ef12c5cd5d8de0ade0c1d27d834ce9816d23e.zip
Get the default values for font height and width in wsfontload(8) using
the WSDISPLAYIO_GETSCREENTYPE ioctl. This ensures that they always match the currently loaded font metrics. Previously, wsfontload(8) hardcoded the default height and width values for the font to be loaded as 12x22 when using framebuffer consoles, and as 8x16 when in text mode. The 12x22 value wasn't correct in case we felt back to the smaller 8x16 font for screen widths smaller than 960px, and wasn't valid anymore since we replaced Gallant 12x22 by Spleen 12x24 on all architectures but sparc64. OK jcs@, mpi@
-rw-r--r--usr.sbin/wsfontload/wsfontload.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/usr.sbin/wsfontload/wsfontload.c b/usr.sbin/wsfontload/wsfontload.c
index a6841a655e3..1ed693f2d67 100644
--- a/usr.sbin/wsfontload/wsfontload.c
+++ b/usr.sbin/wsfontload/wsfontload.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsfontload.c,v 1.22 2020/07/20 14:09:24 fcambus Exp $ */
+/* $OpenBSD: wsfontload.c,v 1.23 2020/08/05 13:56:06 fcambus Exp $ */
/* $NetBSD: wsfontload.c,v 1.2 2000/01/05 18:46:43 ad Exp $ */
/*
@@ -76,6 +76,7 @@ main(int argc, char *argv[])
{
char *wsdev, *infile, *p;
struct wsdisplay_font f;
+ struct wsdisplay_screentype screens;
int c, res, wsfd, ffd, type, list, i;
int defwidth, defheight;
struct stat stat;
@@ -178,23 +179,16 @@ main(int argc, char *argv[])
ffd = STDIN_FILENO;
}
- res = ioctl(wsfd, WSDISPLAYIO_GTYPE, &type);
- if (res != 0)
- type = WSDISPLAY_TYPE_UNKNOWN;
-
- switch (type) {
- /* text-mode VGA */
- case WSDISPLAY_TYPE_ISAVGA:
- case WSDISPLAY_TYPE_PCIVGA:
+ memset(&screens, 0, sizeof(screens));
+ res = ioctl(wsfd, WSDISPLAYIO_GETSCREENTYPE, &screens);
+ if (res == 0) {
+ /* raster frame buffers */
+ defwidth = screens.fontwidth;
+ defheight = screens.fontheight;
+ } else {
+ /* text-mode VGA */
defwidth = 8;
defheight = 16;
- break;
- /* raster frame buffers */
- default:
- /* XXX ought to be computed from the frame buffer resolution */
- defwidth = 12;
- defheight = 22;
- break;
}
f.index = -1;