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

type Font6x8<'a, C> = FontBuilder<'a, C, Font6x8Conf>;

6x8 pixel monospace font

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

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

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

Translate text by (20px, 30px)

use embedded_graphics::prelude::*;
use embedded_graphics::fonts::Font6x8;

display.draw(
    Font6x8::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_6x8 macro are converted into method calls verbatim.

use embedded_graphics::prelude::*;
use embedded_graphics::text_6x8;
use embedded_graphics::fonts::Font6x8;
use embedded_graphics::pixelcolor::Rgb565;

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

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