embedded-text
TextBox for embedded-graphics.
This crate provides a configurable TextBox
to render multiline text inside a bounding
Rectangle
using embedded-graphics.
TextBox
supports the common text alignments:
- Horizontal:
Left
Right
Center
Justified
- Vertical:
Top
Middle
Bottom
TextBox
also supports some special characters not handled by embedded-graphics' Text
:
- non-breaking space (
\u{200b}
) - zero-width space (
\u{a0}
) - soft hyphen (
\u{ad}
) - carriage return (
\r
) - tab (
\t
) with configurable tab size
TextBox
also supports text coloring using ANSI escape codes via the Ansi
plugin.
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 ;
use ;
use ;
Cargo features
plugin
(experimental): allows implementing custom plugins.ansi
: enables ANSI sequence support using theAnsi
plugin.
Development setup
Minimum supported Rust version
The minimum supported Rust version for embedded-text is 1.61.0 or greater. Ensure you have the latest stable version of Rust installed, preferably through https://rustup.rs.
Installation
For setup in general, follow the installation instructions for embedded-graphics.
To install SDL2 on Windows, see https://github.com/Rust-SDL2/rust-sdl2#windows-msvc
Attribution
The last paragraph of the example text is copied from https://www.lipsum.com