Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:PSF console font

From ReverseEngineering.wiki
Format
Versions PSF1; PSF2 version 0
Magic 36 04 (PSF1); 72 B5 4A 86 (PSF2)
Extensions .psf, .psfu, .psf.gz
Endianness little
On this wiki Facts · Code · Notes · Topics

PC Screen Font, the Linux console bitmap font (.psf, .psfu, usually gzipped in /usr/share/consolefonts): PSF1 starts 36 04 with a mode byte and a character size, PSF2 starts 72 B5 4A 86 (little-endian 0x864AB572) with a 32-byte header; fixed-size 1 bit per pixel glyph bitmaps followed by an optional Unicode mapping table.

Overview

A console font file is: header, then the glyph bitmaps (each glyph charsize bytes, rows padded to whole bytes, most significant bit left), then optionally a Unicode table saying which code points each glyph shows. Source: kbd's kfont.h (comment block and structs) and psffontop.c (reader/writer), commit 9c3a59b5ba52.

PSF1

Header of 4 bytes: magic 0x36 0x04, mode, charsize. Width is always 8, so charsize is the height. Mode bits: 0x01 512 glyphs (else 256), 0x02 has a Unicode table, 0x04 table has sequences; kbd rejects mode above 5. Table entries are 16-bit little-endian code points; 0xFFFF ends a glyph's list and 0xFFFE starts the sequences of combining characters. See Fact:PSF console font/struct/PSF1 header.

PSF2

32-byte header, all fields 32-bit little-endian: magic, version (kbd accepts only 0), headersize (offset of the bitmaps), flags (bit 0 = Unicode table), length (glyph count), charsize, height, width. kbd checks charsize = height * ceil(width / 8). The table is UTF-8: 0xFF ends a glyph's list, 0xFE starts sequences. See Fact:PSF console font/struct/PSF2 header.

Identification

Glyph count: PSF1 256 or 512; PSF2 any. Files named .psfu carry a Unicode table. In a program or kernel image the PSF1 magic is only two bytes, so check the mode and that file size matches header + glyphs * charsize.

Code & repositories

  • https://github.com/legionus/kbd @ 9c3a59b5ba52e065e5a5398e728e2b1a41c4983e · license: GPL-2.0-or-later (declared by the contributor; GitHub's detector did not recognize COPYING)
    kbd (GPL-2.0+/LGPL for libkfont): Linux console tools; src/include/kbd/kfont.h defines the PSF1/PSF2 structs and magics, src/libkfont/psffontop.c reads and writes them, data/consolefonts has the fonts.
    Tested on: source read, not run · checked 2026-10-18; last activity 2026-09-27

Pitfalls

  • Unverified: Linux kernel built-in fonts (lib/fonts) are C arrays with a different header and are not PSF; not read here.
  • A PSF2 file may use a width over 8; glyph rows are then bytewidth bytes each.