Crate cfonts

Crate cfonts 

Source
Expand description

§Cfonts - Sexy fonts for the console

$ cfonts "hi there"

██╗  ██╗ ██╗     ████████╗ ██╗  ██╗ ███████╗ ██████╗  ███████╗
██║  ██║ ██║     ╚══██╔══╝ ██║  ██║ ██╔════╝ ██╔══██╗ ██╔════╝
███████║ ██║        ██║    ███████║ █████╗   ██████╔╝ █████╗
██╔══██║ ██║        ██║    ██╔══██║ ██╔══╝   ██╔══██╗ ██╔══╝
██║  ██║ ██║        ██║    ██║  ██║ ███████╗ ██║  ██║ ███████╗
╚═╝  ╚═╝ ╚═╝        ╚═╝    ╚═╝  ╚═╝ ╚══════╝ ╚═╝  ╚═╝ ╚══════╝

💡 This is a silly little command line tool for sexy fonts in the console. Give your cli some love.


This library supports:

  • different fonts
  • multiple colors per font
  • color gradient
  • text alignment
  • letter spacing and line height options

§Usage

Print directly to your console via the println!() macro:

extern crate cfonts;

use cfonts::{ say, Options };

fn main() {
    say(Options {
        text: String::from("hello"),
        ..Options::default()
    });
}

Or use the output struct however you like:

extern crate cfonts;

use cfonts::{ render, Options, Fonts };

fn main() {
    let output = render(Options {
        text: String::from("hello"),
        font: Fonts::FontTiny,
        ..Options::default()
    });

    assert_eq!(
        output.text,
        format!("{}{}{}",
            "\n\n",
            " █ █ █▀▀ █   █   █▀█\n",
            " █▀█ ██▄ █▄▄ █▄▄ █▄█\n\n"
        )
    );

    assert_eq!(output.vec, vec![
        String::from("\n\n █ █ █▀▀ █   █   █▀█"),
        String::from(    " █▀█ ██▄ █▄▄ █▄▄ █▄█\n\n"),
    ]);

    assert_eq!(output.lines, 1);

    assert_eq!(output.options, Options {
        text: String::from("hello"),
        font: Fonts::FontTiny,
        ..Options::default()
    });
}

Re-exports§

pub use color::Rgb;
pub use config::Align;
pub use config::BgColors;
pub use config::Colors;
pub use config::Env;
pub use config::Fonts;
pub use config::Options;
pub use render::render;

Modules§

args
The contents of this module is all about parsing cli arguments
chars
The contents of this module is all about transforming letters on the output vector
cli
The contents of this module is all about cli specific functionality
color
The contents of this module is all about colors, color-transformation and color-conversion
config
The contents of this module is all about the configuration of this package
debug
The contents of this module is all about debugging
font
The contents of this module is all about getting information about our font
gradient
The contents of this module is all about functions to add gradients to the output of cfonts.
helpers
The contents of this module is all about helper functions
render
The contents of this module is all about composing all functions together to render our output

Functions§

say
The say function will print your cfonts output to stdout.