ibm437 0.4.0

IBM437 bitmap font — works with embedded-graphics and raw framebuffers (minifb, softbuffer, SDL2…)
Documentation
# IBM437

The [IBM437](https://en.wikipedia.org/wiki/Code_page_437) bitmap font, extracted from the original AM9264 chip (MDA/CGA card), for Rust projects.

Two rendering backends are available, selected via Cargo features:

- **`embedded-graphics-backend`** — provides [`MonoFont`]https://docs.rs/embedded-graphics/latest/embedded_graphics/mono_font/struct.MonoFont.html constants for the [embedded-graphics]https://crates.io/crates/embedded-graphics ecosystem. Ideal for embedded or simulated displays.
- **`framebuffer`** — renders text into any `&mut [u32]` ARGB pixel buffer. Works with [minifb]https://crates.io/crates/minifb, [softbuffer]https://crates.io/crates/softbuffer, SDL2, or any raw framebuffer.

Both backends can be enabled simultaneously. The raw font data and the Unicode → IBM437 mapping are always available regardless of backend choice.

## Available fonts

Three variants can be toggled individually via features (`regular8x8`, `bold8x8`, `regular9x14`). All three are enabled by default.

### 8×8 regular

![8×8 regular IBM437](https://codeberg.org/sbechet/ibm437/raw/branch/master/doc/ibm437_font_8_8_regular.png)

### 8×8 bold

![8×8 bold IBM437](https://codeberg.org/sbechet/ibm437/raw/branch/master/doc/ibm437_font_8_8_bold.png)

### 9×14 regular

![9×14 regular IBM437](https://codeberg.org/sbechet/ibm437/raw/branch/master/doc/ibm437_font_9_14_regular.png)

## Usage with embedded-graphics

This is the default configuration — no extra feature flags needed.

```toml
[dependencies]
ibm437 = "0.4"
```

```rust
use embedded_graphics::{mono_font::MonoTextStyle, pixelcolor::Rgb888, prelude::*, text::Text};
use ibm437::IBM437_8X8_REGULAR;

let style = MonoTextStyle::new(&IBM437_8X8_REGULAR, Rgb888::WHITE);
Text::new("Hello!", Point::new(10, 20), style)
    .draw(&mut display)?;
```

## Usage with minifb / softbuffer / raw framebuffers

```toml
[dependencies]
ibm437 = { version = "0.4", default-features = false, features = ["framebuffer", "regular8x8"] }
```

```rust
use ibm437::framebuffer::FbFont;

let font = FbFont::regular_8x8();
let mut buffer = vec![0u32; 640 * 480];

// Draw with yellow foreground, transparent background
font.draw_str(&mut buffer, 640, 10, 10, "Hello, IBM437!", 0x00FFFF00, None);

// Draw with white on blue
font.draw_str(&mut buffer, 640, 10, 20, "Line 2", 0x00FFFFFF, Some(0x000000AA));
```

A complete minifb example is available in [`examples/minifb_hello.rs`](examples/minifb_hello.rs).

## Feature reference

| Feature | Default | Description |
|---|---|---|
| `embedded-graphics-backend` || `MonoFont` constants for embedded-graphics |
| `framebuffer` | | `FbFont` renderer for `&mut [u32]` buffers |
| `regular8x8` || Include the 8×8 regular font |
| `bold8x8` || Include the 8×8 bold font |
| `regular9x14` || Include the 9×14 regular font |
| `generate` | | Binary to regenerate fonts from the ROM dump |

## Character set

Glyph offsets are optimised for UTF-8: most Latin-1 characters map to their Unicode code point. The full mapping is available in [`doc/Characters.txt`](doc/Characters.txt).

## License

MIT