Crates.io | tui-big-text |
lib.rs | tui-big-text |
version | 0.7.0 |
source | src |
created_at | 2023-09-05 05:08:28.84449 |
updated_at | 2024-10-25 11:44:12.366733 |
description | A Ratatui widget for displaying big text in the terminal |
homepage | |
repository | https://github.com/joshka/tui-widgets |
max_upload_size | |
id | 963943 |
size | 125,879 |
tui-big-text is a rust crate that renders large pixel text as a Ratatui widget using the glyphs from the font8x8 crate.
GitHub Repository · API Docs · Examples · Changelog · Contributing
cargo add ratatui tui-big-text
Create a BigText
widget using BigText::builder
and pass it to render_widget
to
render be rendered. The builder allows you to customize the Style
of the widget and the
PixelSize
of the glyphs.
use ratatui::prelude::{Frame, Style, Stylize};
use tui_big_text::{BigText, PixelSize};
fn render(frame: &mut Frame) {
let big_text = BigText::builder()
.pixel_size(PixelSize::Full)
.style(Style::new().blue())
.lines(vec![
"Hello".red().into(),
"World".white().into(),
"~~~~~".into(),
])
.build();
frame.render_widget(big_text, frame.size());
}
The PixelSize
can be used to control how many character cells are used to represent a single
pixel of the 8x8 font. It has six variants:
Full
(default) - Each pixel is represented by a single character cell.HalfHeight
- Each pixel is represented by half the height of a character cell.HalfWidth
- Each pixel is represented by half the width of a character cell.Quadrant
- Each pixel is represented by a quarter of a character cell.ThirdHeight
- Each pixel is represented by a third of the height of a character cell.Sextant
- Each pixel is represented by a sixth of a character cell.BigText::builder().pixel_size(PixelSize::Full);
BigText::builder().pixel_size(PixelSize::HalfHeight);
BigText::builder().pixel_size(PixelSize::Quadrant);
Text can be aligned to the Left / Right / Center using the alignment
methods.
BigText::builder().left_aligned();
BigText::builder().centered();
BigText::builder().right_aligned();
Copyright (c) Josh McKinney
This project is licensed under either of:
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
See CONTRIBUTING.md.