# 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`](https://maurycyz.com/projects/mcufont/) C header. Covers `A–Z`, `a–z`, `0–9`, and the punctuation set `- + . , ? ! : = '`. ## Usage — raw ```rust 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`: ```toml mcufont = { version = "0.1", features = ["embedded-graphics"] } ``` Then drop `MCU_FONT` into a `MonoTextStyle`: ```rust 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. ```text 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`](./LICENSE) — see also . ### 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](./CHANGELOG.md) for the relicense, if and when it lands. ## Attribution - 5×5 font data and original C implementation: - Original 5×6 `font-inline.h` it was based on: lcamtuf, - Lineage further traces to the ZX Spectrum 8×8 system font. This Rust crate (scaffolding, `embedded-graphics` integration, tests) is itself a derivative work and is therefore also CC BY-NC-SA 4.0.