#tui #ratatui #terminal #console #text-rendering #customization

tui-big-text

A simple Ratatui widget for displaying big text using the font8x8 crate in a TUI (Terminal UI)

18 unstable releases (3 breaking)

0.4.3 Apr 12, 2024
0.4.2 Feb 26, 2024
0.3.6 Feb 5, 2024
0.3.5 Jan 30, 2024
0.1.4 Sep 5, 2023

#182 in Command-line interface

Download history 37/week @ 2024-01-01 42/week @ 2024-01-08 27/week @ 2024-01-15 54/week @ 2024-01-22 43/week @ 2024-01-29 90/week @ 2024-02-05 191/week @ 2024-02-12 359/week @ 2024-02-19 351/week @ 2024-02-26 73/week @ 2024-03-04 98/week @ 2024-03-11 85/week @ 2024-03-18 15/week @ 2024-03-25 112/week @ 2024-04-01 100/week @ 2024-04-08 887/week @ 2024-04-15

1,136 downloads per month
Used in 4 crates

MIT/Apache

74KB
1K SLoC

tui-big-text

tui-big-text is a rust crate that renders large pixel text as a Ratatui widget using the glyphs from the font8x8 crate.

Demo

Crate badge Docs.rs Badge Deps.rs Badge
License Badge Codecov.io Badge Discord Badge

GitHub Repository · API Docs · Examples · Changelog · Contributing

Installation

cargo add ratatui tui-big-text

Usage

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.

Examples

use anyhow::Result;
use ratatui::prelude::*;
use tui_big_text::{BigText, PixelSize};

fn render(frame: &mut Frame) -> Result<()> {
    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());
    Ok(())
}

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);

Pixel Size

Text can be aligned to the Left / Right / Center using the alignment method.

use ratatui::layout::Alignment;
BigText::builder().alignment(Alignment::Left);
BigText::builder().alignment(Alignment::Right);
BigText::builder().alignment(Alignment::Center);

Alignment Example

License

Copyright (c) 2023 Josh McKinney

This project is licensed under either of

at your option.

Contribution

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.

Dependencies

~6–13MB
~127K SLoC