swaits 2d16125a80 chore: repoint URLs at git.swaits.com and bump for release
Rewrites remaining github.com / git.sr.ht references to git.swaits.com,
translating GitHub URL shapes to Gitea's (/blob/<ref>/ -> /src/branch/<ref>/,
/tree/<tag> -> /src/tag/<tag>, /actions/workflows/X -> /actions?workflow=X,
/edit/ -> /_edit/).

Left pointing at GitHub on purpose: pull-request links (PRs were not migrated)
and GitHub-only surfaces Gitea lacks (security advisories, discussions).
2026-08-31 17:58:35 -06:00
2026-04-29 13:36:29 -06:00
2026-04-29 13:36:29 -06:00
2026-04-29 13:36:29 -06:00
2026-04-29 13:36:29 -06:00
2026-04-29 13:36:29 -06:00

mcufont

Tiny 5×5 monospace pixel font for microcontrollers. no_std, zero dependencies (with default features), ~350 bytes of font data.

Faithful Rust port of Maurycy's mcufont C header. Covers A–Z, a–z, 0–9, and the punctuation set - + . , ? ! : = '.

Usage — raw

use mcufont::{glyph, GLYPH_WIDTH, GLYPH_HEIGHT};

if let Some(g) = glyph('A') {
    for row in g {
        // bit 7 = leftmost pixel, bit 3 = rightmost; bits 2..=0 are zero.
        for x in 0..GLYPH_WIDTH {
            let on = (row >> (7 - x)) & 1 == 1;
            // ... blit to your framebuffer
        }
    }
}

The static tables UPPER, LOWER, DIGITS, SYMBOLS are also public — index them directly if you don't need the lookup function.

Usage — embedded-graphics

Enable the embedded-graphics feature in Cargo.toml:

mcufont = { version = "0.1", features = ["embedded-graphics"] }

Then drop MCU_FONT into a MonoTextStyle:

use embedded_graphics::{
    mono_font::MonoTextStyle, pixelcolor::BinaryColor,
    prelude::*, text::Text,
};
use mcufont::eg::MCU_FONT;

let style = MonoTextStyle::new(&MCU_FONT, BinaryColor::On);
Text::new("Hello", Point::new(0, 5), style).draw(&mut display)?;

Works with any embedded-graphics DrawTarget — SSD1306 over I²C, SH1106, ST7735, fbink, etc.

Features

Feature Default What it adds
upper yes A–Z (130 bytes)
lower yes a–z (130 bytes)
numbers yes 0–9 (50 bytes)
symbols yes - + . , ? ! : = ' (45 bytes)
embedded-graphics no MonoFont integration + concatenated strip (~2× the flash cost)

Disable any category you don't need to save flash. With all four enabled the raw tables sum to ~355 bytes.

Glyph format

Each glyph is [u8; 5] — one byte per row. Pixels are packed in bits 7..=3 MSB-first (bit 7 = leftmost pixel); bits 2..=0 are always zero. This layout matches embedded_graphics::image::ImageRaw byte ordering for a 5-pixel-wide row, so the same bytes drive both the raw API and the embedded-graphics integration with no transformation.

  byte = 0b A B C D E _ _ _   →   row pixels = A B C D E

Embedded targets

Plain static arrays land in .rodata, which is mapped to flash on the common embedded Rust targets — Cortex-M, RISC-V, ESP32, etc. The crate is no_std and uses no allocator. AVR's Harvard architecture (PROGMEM) is not addressed; AVR Rust support is nightly-only and out of scope for this crate.

License — read this

This crate is currently licensed CC BY-NC-SA 4.0 — the only license offered for the upstream font data on the source page. That means:

  • Non-commercial use only. You cannot ship this crate (or work derived from its font data) in a product you sell.
  • ShareAlike. Any derivative work that incorporates the font data must also be licensed under CC BY-NC-SA 4.0.
  • This is not an OSI-approved open-source license. It is incompatible with most permissive and copyleft software licenses.

If those terms don't fit your project, this crate is not for you.

Full license text: LICENSE — see also https://creativecommons.org/licenses/by-nc-sa/4.0/.

Pending relicense

We've reached out to the upstream author asking for a permissive software license (MIT or Apache-2.0) on the original C source. If granted, this crate will be relicensed accordingly and a new version published. Until then the inherited CC BY-NC-SA 4.0 license stands.

Watch the CHANGELOG for the relicense, if and when it lands.

Attribution

This Rust crate (scaffolding, embedded-graphics integration, tests) is itself a derivative work and is therefore also CC BY-NC-SA 4.0.

S
Description
Tiny 5x5 monospace pixel font for microcontrollers — Rust port of Maurycy's mcufont, with optional embedded-graphics integration
Readme CC-BY-SA-4.0
46 KiB
0 Stars 1 Watchers 0 Forks
Languages
Rust 100%