[−][src]Crate embedded_text
TextBox for embedded-graphics
This crate provides a configurable TextBox to render multiline text using embedded-graphics.
TextBox supports the common text alignments:
LeftAlignedRightAlignedCenterAlignedJustified
Example
The examples are based on the embedded-graphics simulator. The simulator is built on top of
SDL2. See the simulator README for more information.

use embedded_graphics_simulator::{ BinaryColorTheme, OutputSettingsBuilder, SimulatorDisplay, Window, }; use embedded_graphics::{ fonts::Font6x8, pixelcolor::BinaryColor, prelude::*, primitives::Rectangle, }; use embedded_text::{alignment::CenterAligned, style::TextBoxStyleBuilder, TextBox}; fn main() -> Result<(), core::convert::Infallible> { let mut display: SimulatorDisplay<BinaryColor> = SimulatorDisplay::new(Size::new(129, 129)); let textbox_style = TextBoxStyleBuilder::new(Font6x8) .alignment(CenterAligned) .text_color(BinaryColor::On) .build(); TextBox::new( "Hello, World!\nLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.", Rectangle::new(Point::zero(), Point::new(128, 128)), ) .into_styled(textbox_style) .draw(&mut display) .unwrap(); let output_settings = OutputSettingsBuilder::new() .theme(BinaryColorTheme::OledBlue) .build(); Window::new("Hello center aligned TextBox", &output_settings).show_static(&display); Ok(()) }
Modules
| alignment | Horizontal text alignment opitons |
| parser | Parse text into smaller units Parse text into words, newlines and whitespace sequences |
| prelude | Prelude |
| rendering | Helpers to render text Pixel iterators used for text rendering |
| style | Textbox styling |
| utils | Helpers Module of small helpers |
Structs
| TextBox | A piece of text with an associated area on the display |