[−][src]Type Definition embedded_graphics::fonts::Font8x16
type Font8x16<'a, C> = FontBuilder<'a, C, Font8x16Conf>;
8x16 pixel monospace font
There is also the text_8x16
macro to provide an easier to use interface.
Examples
Write some text to the screen at the default (0, 0)
position
use embedded_graphics::prelude::*; use embedded_graphics::fonts::Font8x16; use embedded_graphics::text_8x16; // Use struct methods directly display.draw(Font8x16::render_str("Hello Rust!")); // Use a macro instead display.draw(text_8x16!("Hello Rust!"));
Translate text by (20px, 30px)
use embedded_graphics::prelude::*; use embedded_graphics::fonts::Font8x16; display.draw( Font8x16::render_str("Hello Rust!").translate(Coord::new(20, 30)) );
Add some styling to the text
Use any method provided by the WithStyle
trait.
Properties like fill
or stroke
passed to the text_8x16
macro are converted into method
calls verbatim.
use embedded_graphics::prelude::*; use embedded_graphics::text_8x16; use embedded_graphics::fonts::Font8x16; display.draw(text_8x16!( "Hello Rust!", fill = Some(1u8), stroke = Some(0u8) )); display.draw( Font8x16::render_str("Hello Rust!") .translate(Coord::new(20, 30)) .fill(Some(1u8)) .stroke(Some(0u8)), );