Raster Font is a declarative format for authoring and using image-backed fonts.
You may be looking for:
Install
cargo add raster_font
Quick Start
Author a font in TOML:
= "Example Font"
= "font.png"
= "abc$(->|=>)$(:\))Helowrd!"
[]
= [8, 8]
= { = [0, 0], = [8, 8] }
valid returns an iterator of leftmost-longest input matches against the font's glyphs:
use ;
// Fonts with owned resources:
// Fonts with borrowed resources:
Bevy Integration
Load it with Bevy using the bevy feature:
use *;
use *;
;
Feature Flags
| Feature | Description |
|---|---|
bevy |
Enables Bevy asset loading and integration |
font_sequence_map |
Enables direct sequence lookup via RasterFont::get |
Backend Examples
bevy_asset: Demonstrates using the 1st-partyBevyBackendto loadRasterFontassets in the Bevy game engine.macroquad: Minimal backend example for Macroquad
Docs
Full usage including custom backends, layout syntax, and advanced glyph extraction are exhaustively documented at docs.rs/raster_font.
Roadmap
- BIDI: Some form of unicode to support bidirectional text layout. (right-to-left scripts, and mixing of left-to-right and right-to-left text)
- Contextual glyph substitution: e.g. when
Sis followed byT, allow substitution ofSinstead ofSTto enable kerning and ligatures without needing to define separate sequences and glyphs for every combination of characters. - More backends: Raster Font only has one 1st-party backend (bevy), but the API is designed to be backend-agnostic, as long as they have some concept of an image.