Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Bitmap Font for GBA/AGB
Renderer for bitmap fonts on the GBA using the agb framework
Font converter
Use the AGB Font Converter to convert images to fonts
Usage
Loading a font
Two font types are available: FullFont (all 256 code points) and PrintableFont (95 printable ASCII chars, 0x20–0x7E). Load them at compile time with the corresponding macro:
use *;
// Full 256-char font from ROM (default)
let font = full_font!;
// Printable ASCII font, placed in IWRAM for faster blitting
// (~8× fewer waitstates per pixel row — only worthwhile for small fonts ~3 KB)
let font = printable_font!;
// Full 256-char font placed in EWRAM
let font = full_font!;
Rendering text
wrap_at is a maximum line width in pixels (relative to pos). Pass None to disable wrapping.
use *;
use vec2;
let mut renderer = default;
renderer.draw_text;
Typewriter effect
TypewriterRenderer reveals text one chunk at a time. Call update() once per frame and draw() to blit newly revealed characters.
use *;
use vec2;
// 1 character revealed every 2 frames, wrap at 200px
let mut tw = new;
tw.load_text;
loop
To clear the text area before loading new text:
tw.clear;
tw.load_text;
Font binary format
Two modes are supported, selected by the mode byte at offset 0.
Common header
| Offset | Size | Field |
|---|---|---|
| 0 | 1 | mode — 0 = printable ASCII, 1 = all-256 |
| 1 | 1 | glyph_width — glyph cell width in pixels |
| 2 | 1 | glyph_height — glyph cell height in pixels |
Mode 0 — printable ASCII (95 glyphs)
| Offset | Size | Field |
|---|---|---|
| 3 | 95 | char_widths — advance width per character, ascending byte order |
| 98 | 2 | padding to 4-byte boundary |
| 100 | varies | 4bpp pixel data |
Mode 1 — all-256 (256 glyphs)
| Offset | Size | Field |
|---|---|---|
| 3 | 256 | char_widths — advance width per code point |
| 259 | 1 | padding to 4-byte boundary |
| 260 | varies | 4bpp pixel data |
Pixel data
Stored as u32 values, each holding 8 pixels at 4 bits per pixel (4bpp). Each glyph row occupies (glyph_width + 7) / 8 u32s. Palette index 0 is transparent.