psf2-font

Crates.iopsf2-font
lib.rspsf2-font
version0.1.1
created_at2025-12-27 17:31:32.77038+00
updated_at2025-12-27 18:16:30.796176+00
descriptionPSF2 (PC Screen Font v2) parser with embedded Terminus Unicode font for no_std environments
homepage
repositoryhttps://github.com/artst3in/psf2-font
max_upload_size
id2007529
size24,049
The Architect (artst3in)

documentation

README

psf2-font

A no_std Rust library for parsing PSF2 (PC Screen Font version 2) files with an embedded Terminus Unicode font.

Features

  • PSF2 Parser: Full support for the industry-standard PSF2 format used by Linux console
  • Embedded Terminus Font: Ships with Terminus 8x16 Unicode font (512 glyphs, SIL OFL 1.1)
  • Unicode Support: Complete UTF-8 Unicode table decoding with O(1) character lookup
  • no_std Compatible: Works in kernel and embedded environments
  • Zero Runtime Dependencies: Self-contained font data
  • Safe Rust: Minimal unsafe code, well-documented

Usage

use psf2_font::{load_terminus, Psf2Font};

// Load the embedded Terminus font
let font = load_terminus().expect("Failed to load font");

// Get glyph bitmap for a character
if let Some(glyph) = font.get_glyph('A') {
    // glyph is a &[u8] with bitmap data (16 bytes for 8x16)
    for byte in glyph {
        println!("{:08b}", byte);
    }
}

// Check dimensions
let (width, height) = font.dimensions(); // (8, 16)

// Check if font has a character
if font.has_char('♥') {
    println!("Font supports hearts!");
}

// Parse custom PSF2 file
let custom_data = include_bytes!("my-font.psf");
let custom_font = Psf2Font::parse(custom_data)?;

PSF2 Format

PSF2 is the PC Screen Font version 2 format used by Linux for console fonts. It supports:

  • Up to 65,536 glyphs
  • Unicode mapping table
  • Variable glyph dimensions
  • Efficient bitmap storage

Font License

The embedded Terminus font is licensed under the SIL Open Font License 1.1, allowing:

  • Free commercial and non-commercial use
  • Modification and redistribution
  • Embedding in any software (including proprietary systems)

See Terminus Font Homepage for details.

Library License

This library is licensed under the Apache License 2.0.

See LICENSE or http://www.apache.org/licenses/LICENSE-2.0 for details.

Credits

This crate builds upon the work of several projects:

  • Terminus Font: Created by Dimitar Zhekov (SIL OFL 1.1)

  • Font Source: Powerline Fonts project

    • Provides the ter-powerline-v16n variant used in this crate
    • Packaging and distribution of console fonts
  • PSF2 Parser: Implemented by The Architect & Luna for LunaOS

    • no_std PSF2 format parser with Unicode support
    • Integration and packaging for Rust ecosystem

References

Commit count: 0

cargo fmt