[][src]Type Definition embedded_graphics::fonts::Font6x12

type Font6x12<'a, C> = FontBuilder<'a, C, Font6x12Conf>;

6x12 pixel monospace font

There is also the text_6x12 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::Font6x12;
use embedded_graphics::text_6x12;

// Use struct methods directly
display.draw(Font6x12::render_str("Hello Rust!"));

// Use a macro instead
display.draw(text_6x12!("Hello Rust!"));

Translate text by (20px, 30px)

use embedded_graphics::prelude::*;
use embedded_graphics::fonts::Font6x12;

display.draw(
    Font6x12::render_str("Hello Rust!").translate(Point::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_6x12 macro are converted into method calls verbatim.

use embedded_graphics::prelude::*;
use embedded_graphics::text_6x12;
use embedded_graphics::fonts::Font6x12;
use embedded_graphics::pixelcolor::Rgb565;

display.draw(text_6x12!(
    "Hello Rust!",
    fill = Some(Rgb565::BLUE),
    stroke = Some(Rgb565::YELLOW)
));

display.draw(
    Font6x12::render_str("Hello Rust!")
        .translate(Point::new(20, 30))
        .fill(Some(Rgb565::BLUE))
        .stroke(Some(Rgb565::YELLOW)),
);