Index | Thread | Search

From:
Frederic Cambus <fred@statdns.com>
Subject:
file(1): add support for Web Open Font Format (WOFF) detection
To:
tech@openbsd.org
Date:
Wed, 28 Jan 2026 21:49:55 +0100

Download raw body.

Thread
  • Frederic Cambus:

    file(1): add support for Web Open Font Format (WOFF) detection

Hi tech@,

Here is a diff to add support for Web Open Font Format detection. From NetBSD.

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

Currently, file returns "data" for WOFF and WOFF2 fonts.

With the diff applied:

$ file *.woff*
spleen-12x24.woff:  Web Open Font Format, CFF, length 24748, version 2.6553
spleen-12x24.woff2: Web Open Font Format (Version 2), CFF, length 21484, version 2.6553
spleen-16x32.woff:  Web Open Font Format, CFF, length 17668, version 2.6553
spleen-16x32.woff2: Web Open Font Format (Version 2), CFF, length 15872, version 2.6553
spleen-32x64.woff:  Web Open Font Format, CFF, length 20696, version 2.6553
spleen-32x64.woff2: Web Open Font Format (Version 2), CFF, length 17640, version 2.6553
spleen-6x12.woff:   Web Open Font Format, CFF, length 7892, version 2.6553
spleen-6x12.woff2:  Web Open Font Format (Version 2), CFF, length 7128, version 2.6553
spleen-8x16.woff:   Web Open Font Format, CFF, length 16064, version 2.6553
spleen-8x16.woff2:  Web Open Font Format (Version 2), CFF, length 14416, version 2.6553

Comments? OK?

Index: usr.bin/file/magdir/fonts
===================================================================
RCS file: /cvs/src/usr.bin/file/magdir/fonts,v
diff -u -p -r1.5 fonts
--- usr.bin/file/magdir/fonts	24 Apr 2009 18:54:34 -0000	1.5
+++ usr.bin/file/magdir/fonts	27 Jan 2026 19:24:47 -0000
@@ -63,3 +63,30 @@
 # Gürkan Sengün <gurkan@linuks.mine.nu>, www.linuks.mine.nu 
 0	string		SplineFontDB:	Spline Font Database 
 >14	string		x		version %s
+
+# Web Open Font Format (.woff)
+0	name		woff
+>4	belong		0x00010000	\b, TrueType
+>4	belong		0x4F54544F	\b, CFF
+>4	belong		0x74727565	\b, TrueType
+>4	default		x
+>>4	belong		x		\b, flavor %d
+>8	belong		x		\b, length %d
+#>12	beshort		x		\b, numTables %d
+#>14	beshort		x		\b, reserved %d
+#>16	belong		x		\b, totalSfntSize %d
+
+# https://www.w3.org/TR/WOFF/
+0	string		wOFF	Web Open Font Format
+!:mime font/woff
+>0	use		woff
+>20	beshort		x	\b, version %d
+>22	beshort		x	\b.%d
+# https://www.w3.org/TR/WOFF2/
+0	string		wOF2	Web Open Font Format (Version 2)
+!:mime font/woff2
+!:ext	woff2
+>0	use		woff
+#>20	belong		x	\b, totalCompressedSize %d
+>24	beshort		x	\b, version %d
+>26	beshort		x	\b.%d