Index | Thread | Search

From:
Frederic Cambus <fred@statdns.com>
Subject:
file(1): add support for PSF2 fonts detection
To:
tech@openbsd.org
Date:
Sat, 17 Jan 2026 22:35:22 +0100

Download raw body.

Thread
Hi tech@,

Here is a diff to add support for PSF2 fonts detection. From NetBSD.

Reference: https://cvsweb.netbsd.org/bsdweb.cgi/src/external/bsd/file/dist/magic/magdir/linux

Currently, file returns "data" for PSF 2 fonts:

$ file *.psfu
spleen-12x24.psfu: data
spleen-16x32.psfu: data
spleen-32x64.psfu: data
spleen-5x8.psfu:   data
spleen-6x12.psfu:  data
spleen-8x16.psfu:  Linux/i386 PC Screen Font data, 512 characters, Unicode directory, 8x16

With the diff applied:

$ file *.psfu
spleen-12x24.psfu: Linux/i386 PC Screen Font v2 data, 512 characters, Unicode directory, 12x24
spleen-16x32.psfu: Linux/i386 PC Screen Font v2 data, 512 characters, Unicode directory, 16x32
spleen-32x64.psfu: Linux/i386 PC Screen Font v2 data, 512 characters, Unicode directory, 32x64
spleen-5x8.psfu:   Linux/i386 PC Screen Font v2 data, 512 characters, Unicode directory, 5x8
spleen-6x12.psfu:  Linux/i386 PC Screen Font v2 data, 512 characters, Unicode directory, 6x12
spleen-8x16.psfu:  Linux/i386 PC Screen Font v1 data, 512 characters, Unicode directory, 8x16

Comments? OK?

Index: usr.bin/file/magdir/linux
===================================================================
RCS file: /cvs/src/usr.bin/file/magdir/linux,v
diff -u -p -r1.6 linux
--- usr.bin/file/magdir/linux	24 Apr 2009 18:54:34 -0000	1.6
+++ usr.bin/file/magdir/linux	17 Jan 2026 19:22:40 -0000
@@ -46,12 +46,20 @@
 2	string		LILO		Linux/i386 LILO boot/chain loader
 #
 # PSF fonts, from H. Peter Anvin <hpa@yggdrasil.com>
-0	leshort		0x0436		Linux/i386 PC Screen Font data,
->2	byte		0		256 characters, no directory,
->2	byte		1		512 characters, no directory,
->2	byte		2		256 characters, Unicode directory,
->2	byte		3		512 characters, Unicode directory,
+# Updated by Adam Buchbinder <adam.buchbinder@gmail.com>
+# See: https://www.win.tue.nl/~aeb/linux/kbd/font-formats-1.html
+0	leshort		0x0436		Linux/i386 PC Screen Font v1 data,
+>2	byte&0x01	0		256 characters,
+>2	byte&0x01	!0		512 characters,
+>2	byte&0x02	0		no directory,
+>2	byte&0x02	!0		Unicode directory,
 >3	byte		>0		8x%d
+0	string		\x72\xb5\x4a\x86\x00\x00 Linux/i386 PC Screen Font v2 data,
+>16	lelong		x		%d characters,
+>12	lelong&0x01	0		no directory,
+>12	lelong&0x01	!0		Unicode directory,
+>28	lelong		x		%d
+>24	lelong		x		\bx%d
 # Linux swap file, from Daniel Quinlan <quinlan@yggdrasil.com>
 4086	string		SWAP-SPACE	Linux/i386 swap file
 # From: Jeff Bailey <jbailey@ubuntu.com>