Macro embedded_graphics::text_style
source · [−]macro_rules! text_style {
(font = $font:expr, $( $style_key:ident = $style_value:expr ),* $(,)?) => { ... };
(font = $font:expr $(,)?) => { ... };
}
Expand description
Create a TextStyle
All properties on TextStyle
are supported. At least font
is required, and must be the
first property passed to the macro.
Examples
Create a default text style
This example uses [Font8x16
] and the [Rgb565
] color space to create a default text style.
This will result in a white font with transparent background.
use embedded_graphics::{
fonts::Font8x16,
pixelcolor::{Rgb565, RgbColor},
style::TextStyle,
text_style,
};
let style: TextStyle<Rgb565, _> = text_style!(font = Font8x16);
Create colored text with background
This example uses [Font6x8
] and the [Rgb565
] color space to create a text style with red
text on a green background.
use embedded_graphics::{
fonts::Font6x8,
pixelcolor::{Rgb565, RgbColor},
style::TextStyle,
text_style,
};
let style = text_style!(
font = Font6x8,
text_color = Rgb565::RED,
background_color = Rgb565::GREEN
);