| Crates.io | prettychars |
| lib.rs | prettychars |
| version | 0.1.0 |
| created_at | 2025-12-17 13:53:57.899981+00 |
| updated_at | 2025-12-17 13:53:57.899981+00 |
| description | Unicode text styling and named glyph lookup with zero runtime overhead |
| homepage | |
| repository | https://github.com/blackwell-systems/prettychars |
| max_upload_size | |
| id | 1990258 |
| size | 69,455 |
Unicode text styling and named glyph lookup with zero runtime overhead.
arrow.right or star.filledAdd to your Cargo.toml:
[dependencies]
prettychars = "0.1"
use prettychars::{style, Style};
// Mathematical styles
let bold = style("Hello", Style::MathBold); // ๐๐๐ฅ๐ฅ๐จ
let italic = style("World", Style::Italic); // ๐๐๐๐๐
let mono = style("Code", Style::Monospace); // ๐ฒ๐๐๐
// Enclosed styles
let circled = style("RUST", Style::Circled); // โโโโ
let squared = style("WARN", Style::Squared); // ๐
๐ฐ๐
๐ฝ
// Typography
let fancy = style("Script", Style::Script); // ๐ฎ๐ธ๐๐พ๐
๐
let gothic = style("Fraktur", Style::Fraktur); // ๐๐ฏ๐๐จ๐ฑ๐ฒ๐ฏ
// Technical
let wide = style("Full", Style::Fullwidth); // ๏ผฆ๏ฝ๏ฝ๏ฝ
let small = style("CAPS", Style::SmallCaps); // แดแดแด๊ฑ
use prettychars::glyph;
// Arrows
println!("{}", glyph("arrow.right").unwrap()); // โ
println!("{}", glyph("arrow.double-left").unwrap()); // โ
// Box drawing
println!("{}", glyph("box.light.tl").unwrap()); // โ
println!("{}", glyph("box.heavy.cross").unwrap()); // โ
// Symbols
println!("{}", glyph("check.mark").unwrap()); // โ
println!("{}", glyph("star.filled").unwrap()); // โ
println!("{}", glyph("heart").unwrap()); // โฅ
// Math
println!("{}", glyph("math.infinity").unwrap()); // โ
println!("{}", glyph("math.sum").unwrap()); // โ
// Currency
println!("{}", glyph("currency.euro").unwrap()); // โฌ
println!("{}", glyph("currency.bitcoin").unwrap()); // โฟ
use prettychars::{glyph_names, style_names};
// Find all arrow glyphs
for name in glyph_names().filter(|n| n.starts_with("arrow.")) {
println!("{}: {}", name, glyph(name).unwrap());
}
// List all available styles
for style in style_names() {
println!("{:?}", style);
}
Combine multiple prettychars operations for rich terminal interfaces:
use prettychars::{glyph, style, Style};
// Progress bars with mixed elements
let progress = format!(
"{} [{}{}] {}% {}",
glyph("arrow.right").unwrap(),
glyph("block.full").unwrap().repeat(7),
glyph("block.left.4").unwrap(),
75,
glyph("check.mark").unwrap()
);
// Status indicators with styled text
let status = format!("{} {}",
glyph("misc.warning").unwrap(),
style("HIGH CPU", Style::MathBold)
);
// Complex UI elements
let title = format!("{} {} {}",
glyph("star").unwrap(),
style("DASHBOARD", Style::SmallCaps),
glyph("star").unwrap()
);
See examples/chaining.rs for complete patterns.
MathBold - Bold (๐๐๐๐๐๐๐๐๐)Italic - Italic (๐ด๐ต๐ถ๐๐๐)BoldItalic - Bold italic (๐จ๐ฉ๐ช๐๐๐)DoubleStruck - Blackboard bold (๐ธ๐นโ๐๐๐๐๐๐)Circled - Circled letters (โถโทโธโถโทโธ)CircledNegative - Negative circled (๐
๐
๐
)Squared - Squared letters (๐ฐ๐ฑ๐ฒ)SquaredNegative - Negative squared (๐
ฐ๐
ฑ๐
ฒ)Parenthesized - Parenthesized (โโโ)Fraktur - Gothic/Blackletter (๐๐
๐๐๐๐ )FrakturBold - Bold Fraktur (๐ฌ๐ญ๐ฎ๐๐๐)Script - Calligraphic (๐โฌ๐๐ถ๐ท๐ธ)ScriptBold - Bold script (๐๐๐๐ช๐ซ๐ฌ)SmallCaps - Small capitals (แดสแด)Monospace - Fixed-width (๐ฐ๐ฑ๐ฒ๐๐๐๐ถ๐ท๐ธ)Fullwidth - East Asian fullwidth (๏ผก๏ผข๏ผฃ๏ฝ๏ฝ๏ฝ๏ผ๏ผ๏ผ)SansSerif - Sans-serif (๐ ๐ก๐ข๐บ๐ป๐ผ๐ข๐ฃ๐ค)SansSerifBold - Bold sans-serif (๐๐๐๐ฎ๐ฏ๐ฐ๐ฌ๐ญ๐ฎ)SansSerifItalic - Italic sans-serif (๐๐๐๐ข๐ฃ๐ค)SansSerifBoldItalic - Bold italic sans-serif (๐ผ๐ฝ๐พ๐๐๐)Superscript - Raised (แดฌแดฎแถโฐยนยฒ)Subscript - Lowered (โโโโโโ)Strikethrough - Struck through (AฬถBฬถCฬถ)Inverted - Upside down (ษqษ)The 531 named glyphs are organized into categories:
All glyph lookups use PHF (Perfect Hash Function) to generate compile-time hash maps. This means:
All glyphs have VS15 (U+FE0E, Variation Selector-15) applied automatically. VS15 requests text-style rendering rather than emoji-style rendering, ensuring consistent appearance across platforms. This is completely transparent to callers.
The glyph name registry is append-only. Names are never removed or changed once published, ensuring your code won't break with updates. New glyphs may be added in minor version releases.
Benchmarking on a modern CPU shows:
The entire compiled PHF map for 531 glyphs adds approximately 8KB to your binary.
std::fmt for errors)use prettychars::glyph;
fn draw_progress(percent: u8) {
let filled = glyph("block.full").unwrap();
let empty = glyph("block.empty").unwrap();
let bar_width = 20;
let filled_count = (percent as usize * bar_width) / 100;
print!("[");
for i in 0..bar_width {
print!("{}", if i < filled_count { filled } else { empty });
}
println!("] {}%", percent);
}
draw_progress(65); // [โโโโโโโโโโโโโโโโโโโโ] 65%
use prettychars::{style, glyph, Style};
fn log_message(level: &str, msg: &str) {
let (symbol, styled_level) = match level {
"error" => (glyph("check.x.heavy").unwrap(),
style("ERROR", Style::MathBold)),
"warn" => (glyph("misc.warning").unwrap(),
style("WARN", Style::Squared)),
"info" => (glyph("check.mark").unwrap(),
style("INFO", Style::Circled)),
_ => ("?", level.to_string()),
};
println!("{} {} {}", symbol, styled_level, msg);
}
use prettychars::glyph;
fn draw_table() {
let tl = glyph("box.heavy.tl").unwrap();
let tr = glyph("box.heavy.tr").unwrap();
let bl = glyph("box.heavy.bl").unwrap();
let br = glyph("box.heavy.br").unwrap();
let h = glyph("box.heavy.h").unwrap();
let v = glyph("box.heavy.v").unwrap();
println!("{}{:โ<20}{}", tl, "", tr);
println!("{} {:18} {}", v, "Table Content", v);
println!("{}{:โ<20}{}", bl, "", br);
}
Run these examples to see prettychars in action:
Chess Board (cargo run --example chessboard)
System Dashboard (cargo run --example dashboard)
Both examples demonstrate:
Note: GitHub's markdown renderer cannot properly display Unicode box-drawing alignment. The examples render perfectly in actual terminals. See TERMINAL_COMPATIBILITY.md for terminal-specific guidance.
Licensed under either of:
at your option.
Contributions are welcome! Please feel free to submit a Pull Request.
When suggesting new glyphs, please ensure they:
Extracted from the mdfx project by Blackwell Systems, this crate provides the Unicode styling and glyph functionality as a standalone library.