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

type Font12x16<'a, C> = FontBuilder<'a, C, Font12x16Conf>;

12x16 pixel monospace font

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

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

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

Translate text by (20px, 30px)

use embedded_graphics::prelude::*;
use embedded_graphics::fonts::Font12x16;

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

use embedded_graphics::prelude::*;
use embedded_graphics::text_12x16;
use embedded_graphics::fonts::Font12x16;
use embedded_graphics::pixelcolor::Rgb565;

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

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