From owner-freebsd-current@FreeBSD.ORG Sat Sep 13 14:05:45 2014 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 771528DC for ; Sat, 13 Sep 2014 14:05:45 +0000 (UTC) Received: from m.saper.info (m.saper.info [IPv6:2a01:4f8:a0:7383::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "m.saper.info", Issuer "Marcin Cieslak 2011" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 22CFEC86 for ; Sat, 13 Sep 2014 14:05:44 +0000 (UTC) Received: from localhost (saper@localhost [127.0.0.1]) by m.saper.info (8.14.9/8.14.9) with ESMTP id s8DE5etd075816 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 13 Sep 2014 14:05:41 GMT (envelope-from saper@saper.info) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=saper.info; s=Sep2014; t=1410617142; bh=HWmod98+fGg7HLuxzuhZj3K34W5b8s7Jqo1jkTRVdcU=; h=Date:From:To:Subject; b=qSbV4GrS+SHyIV++KOYp0q7qUBL1AR6O8lBTnnKjHQ+gAAQswXOGH/XYq8hfpW6OO j5lxP4z4GdfHiL5gwvtv8BFpDmIy9xi66Bzw64M8sDGZtDHaRrEPcOBhDlTfR4149x IpfOGvXDaT9wyVtKnUrXioRq3pRXX0ydPShAw4Ic= Date: Sat, 13 Sep 2014 14:05:40 +0000 (UTC) From: Marcin Cieslak To: freebsd-current@FreeBSD.org Subject: Teach vidcontrol(1) and vt(4) to restore default font Message-ID: User-Agent: Alpine 2.11 (BSF 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Sep 2014 14:05:45 -0000 Hello, I tried loading gallant.fnt which I did not like and I was wondering how to come back to the nice default font. There does not seem to be the way to do this, so please find below a simple patch to add this functionality. It adds a new ioctl PIO_VDFFONT to the vt(4) driver. I hope I got the reference counting on the vt_font_default structure right. With this patch applied, "vidcontrol -f" restores the built-in font. //Marcin Index: sys/dev/vt/vt_core.c =================================================================== --- sys/dev/vt/vt_core.c (wersja 271197) +++ sys/dev/vt/vt_core.c (kopia robocza) @@ -1948,6 +1948,10 @@ vtfont_unref(vf); return (error); } + case PIO_VDFTFONT: { + error = vt_change_font(vw, &vt_font_default); + return (error); + } case GIO_SCRNMAP: { scrmap_t *sm = (scrmap_t *)data; Index: sys/sys/consio.h =================================================================== --- sys/sys/consio.h (wersja 271197) +++ sys/sys/consio.h (kopia robocza) @@ -239,6 +239,7 @@ #define GIO_FONT8x16 _IOR('c', 69, fnt16_t) #define PIO_VFONT _IOW('c', 70, vfnt_t) #define GIO_VFONT _IOR('c', 71, vfnt_t) +#define PIO_VDFTFONT _IO('c', 72) /* get video mode information */ struct colors { Index: usr.sbin/vidcontrol/vidcontrol.1 =================================================================== --- usr.sbin/vidcontrol/vidcontrol.1 (wersja 271197) +++ usr.sbin/vidcontrol/vidcontrol.1 (kopia robocza) @@ -26,9 +26,11 @@ .Op Fl c Ar appearance .Oo .Fl f +.Oo .Op Ar size .Ar file .Oc +.Oc .Op Fl g Ar geometry .Op Fl h Ar size .Op Fl i Cm adapter | mode @@ -136,8 +138,10 @@ Print out current output screen map. .It Xo .Fl f +.Oo .Op Ar size .Ar file +.Oc .Xc Load font .Ar file @@ -158,6 +162,14 @@ .Nm will try to guess it from the size of font file. .Pp +When using +.Xr vt 4 +both +.Ar size +and +.Ar font +can be omitted, and the default font will be loaded. +.Pp Note that older video cards, such as MDA and CGA, do not support software font. See also Index: usr.sbin/vidcontrol/vidcontrol.c =================================================================== --- usr.sbin/vidcontrol/vidcontrol.c (wersja 271197) +++ usr.sbin/vidcontrol/vidcontrol.c (kopia robocza) @@ -197,7 +197,7 @@ { if (vt4_mode) fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n", -"usage: vidcontrol [-CHPpx] [-b color] [-c appearance] [-f [size] file]", +"usage: vidcontrol [-CHPpx] [-b color] [-c appearance] [-f [[size] file]]", " [-g geometry] [-h size] [-i adapter | mode]", " [-M char] [-m on | off] [-r foreground background]", " [-S on | off] [-s number] [-T xterm | cons25] [-t N | off]", @@ -409,6 +409,19 @@ return (t); } +/* + * Set the default vt font. + */ + +static void +load_default_vt4font(void) +{ + if (ioctl(0, PIO_VDFTFONT) == -1) { + revert(); + errc(1, errno, "loading default vt font"); + } +} + static int load_vt4font(FILE *f) { @@ -1328,7 +1341,7 @@ dumpopt = DUMP_FBF; termmode = NULL; if (vt4_mode) - opts = "b:Cc:f:g:h:Hi:M:m:pPr:S:s:T:t:x"; + opts = "b:Cc:fg:h:Hi:M:m:pPr:S:s:T:t:x"; else opts = "b:Cc:df:g:h:Hi:l:LM:m:pPr:S:s:T:t:x"; @@ -1349,15 +1362,23 @@ print_scrnmap(); break; case 'f': - type = optarg; - font = nextarg(argc, argv, &optind, 'f', 0); + optarg = nextarg(argc, argv, &optind, 'f', 0); + if (optarg != NULL) { + font = nextarg(argc, argv, &optind, 'f', 0); - if (font == NULL) { - type = NULL; - font = optarg; + if (font == NULL) { + type = NULL; + font = optarg; + } else + type = optarg; + + load_font(type, font); + } else { + if (!vt4_mode) + usage(); /* Switch syscons to ROM? */ + + load_default_vt4font(); } - - load_font(type, font); break; case 'g': if (sscanf(optarg, "%dx%d",