Expand description
Font rendering (ttf and otf) with embedded-graphics.
Embedded graphics provides static mono font rendering directly from the code. But it can render any font if the proper trait is implemented.
This is an implementation that uses the rusttype
crate to parse ttf and otf fonts before rendering them on a DrawTarget
§Usage
Use FontTextStyleBuilder to easily create a FontTextStyle object.
This style can then be directly used with embedded graphics’ [Text] struct.
let mut display: SimulatorDisplay<Rgb565> = SimulatorDisplay::new(Size::new(350, 200));
let style = FontTextStyleBuilder::new(
Font::try_from_bytes(include_bytes!("../assets/Roboto-Regular.ttf")).unwrap())
.font_size(16)
.text_color(Rgb565::WHITE)
.build();
Text::new("Hello World!", Point::new(15, 30), style).draw(&mut display)?;Structs§
- Font
Text Style - Style properties for text using a ttf and otf font.
- Font
Text Style Builder - Text style builder for ttf and otf fonts.