| Crates.io | textbox |
| lib.rs | textbox |
| version | 0.5.0 |
| created_at | 2025-12-19 19:26:16.498101+00 |
| updated_at | 2025-12-19 19:26:16.498101+00 |
| description | An elegant utility for slotting text/images into named slots in templates. |
| homepage | |
| repository | https://github.com/Ersox/textbox |
| max_upload_size | |
| id | 1995364 |
| size | 58,396 |
textboxAn elegant utility for constructing templates that can have text or images slotted into an existing layout.
By initializing a TextBox, you can define a template image and place named components on it:
TextArea) for rendering textImageArea) for overlaying imagesOnce the template is defined, you can fill in content at runtime with a TextBoxRender, placing text and images in predictable slots.
let mut template: DynamicImage = /* ... */;
let text_box = TextBox::new(template)
.image_component("flag", ImageArea::new((0, 0)))
.text_component("name", TextArea::new(
(0, 200),
400,
BLACK,
FontArc::try_from_slice(include_bytes!("path/to/font.ttf"))?,
48.0,
Align::Center
));
let flag: DynamicImage = /* ... */;
let render = TextBoxRender::new()
.image("flag", flag)
.text("name", "Germany");
let img = text_box.render(render)?;
--
TextBox is dependent on the image, imageproc and ab_glyph crates. The goal is to make it easy to create reusable containers for slotting images and text into predictable slots.
Text fields allow for a subset of markdown styles if the provided font is a variable font, like Roboto Flex. Bold, italic, and colored styles are usable. Colored styles use Markdown link syntax, i.e. [Colored Text](#FF0000), since static images could never be clickable links anyway. If the font doesn't support those features, all styles will be ignored.