Hi tech@,

Currently, wsfontload(8) hardcodes 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 isn't valid anymore since we replaced Gallant 12x22 by Spleen 12x24
on all architectures but sparc64.
 
Here is a diff to get the default values for font height and width using
the WSDISPLAYIO_GETSCREENTYPE ioctl. This ensures that they always match
the currently loaded font metrics.

Tested on a system with a text mode console only, on efifb(4) and
inteldrm(4) framebuffer consoles, and on Loongson with smfb(4).

Please note that this needs the diff I sent to tech@ yesterday to allow
the WSDISPLAYIO_GETSCREENTYPE ioctl on tty*cfg.

Comments? OK?

Index: usr.sbin/wsfontload/wsfontload.c
===================================================================
RCS file: /cvs/src/usr.sbin/wsfontload/wsfontload.c,v
retrieving revision 1.22
diff -u -p -r1.22 wsfontload.c
--- usr.sbin/wsfontload/wsfontload.c    20 Jul 2020 14:09:24 -0000      1.22
+++ usr.sbin/wsfontload/wsfontload.c    21 Jul 2020 10:41:56 -0000
@@ -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;

Reply via email to