Module Name:    src
Committed By:   mlelstv
Date:           Sun Oct 20 09:25:00 UTC 2024

Modified Files:
        src/sys/dev/wscons: wsconsio.h wsdisplay_vcons.c

Log Message:
Add WSDISPLAYIO_GFONT ioctl to query the installed font name.


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sys/dev/wscons/wsconsio.h
cvs rdiff -u -r1.68 -r1.69 src/sys/dev/wscons/wsdisplay_vcons.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/wscons/wsconsio.h
diff -u src/sys/dev/wscons/wsconsio.h:1.128 src/sys/dev/wscons/wsconsio.h:1.129
--- src/sys/dev/wscons/wsconsio.h:1.128	Sun Oct 20 08:44:22 2024
+++ src/sys/dev/wscons/wsconsio.h	Sun Oct 20 09:25:00 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: wsconsio.h,v 1.128 2024/10/20 08:44:22 mlelstv Exp $ */
+/* $NetBSD: wsconsio.h,v 1.129 2024/10/20 09:25:00 mlelstv Exp $ */
 
 /*
  * Copyright (c) 1996, 1997 Christopher G. Demetriou.  All rights reserved.
@@ -730,4 +730,20 @@ struct wsdisplayio_fontinfo {
 
 #define WSDISPLAYIO_LISTFONTS	_IOWR('W', 107, struct wsdisplayio_fontinfo)
 
+struct wsdisplay_getfont {
+	char *gf_name;
+	uint32_t gf_size;
+	uint32_t gf_actual;
+};
+
+/*
+ * return currently active font
+ *
+ * gf_name points to a buffer of gf_size bytes, the result may be truncated
+ * and NUL-terminated.
+ * gf_actual is set to the size of full name.
+ */
+
+#define WSDISPLAYIO_GFONT	_IOWR('W', 108, struct wsdisplay_getfont)
+
 #endif /* _DEV_WSCONS_WSCONSIO_H_ */

Index: src/sys/dev/wscons/wsdisplay_vcons.c
diff -u src/sys/dev/wscons/wsdisplay_vcons.c:1.68 src/sys/dev/wscons/wsdisplay_vcons.c:1.69
--- src/sys/dev/wscons/wsdisplay_vcons.c:1.68	Fri Feb  9 22:08:37 2024
+++ src/sys/dev/wscons/wsdisplay_vcons.c	Sun Oct 20 09:25:00 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: wsdisplay_vcons.c,v 1.68 2024/02/09 22:08:37 andvar Exp $ */
+/*	$NetBSD: wsdisplay_vcons.c,v 1.69 2024/10/20 09:25:00 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2005, 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.68 2024/02/09 22:08:37 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.69 2024/10/20 09:25:00 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -841,6 +841,20 @@ vcons_ioctl(void *v, void *vs, u_long cm
 		}
 		break;
 
+	case WSDISPLAYIO_GFONT: {
+		struct wsdisplay_getfont *gf = data;
+		size_t actual;
+		struct wsdisplay_font *font;
+		const char *fontname;
+
+		font = ((struct vcons_screen *)vs)->scr_ri.ri_font;
+		fontname = font && font->name ? font->name : "";
+		error = copyoutstr(fontname, gf->gf_name, gf->gf_size, &actual);
+		if (!error)
+			gf->gf_actual = actual;
+		}
+		break;
+
 	default:
 		if (vdp->ioctl != NULL)
 			error = (*vdp->ioctl)(v, vs, cmd, data, flag, l);

Reply via email to