pub struct Figlet { /* private fields */ }Expand description
A reusable renderer holding a parsed Font and resolved layout
settings.
Cheap to clone; clone the Figlet across threads to render many
banners concurrently with the same font configuration.
use rusty_figlet::{FigletBuilder, Font};
let figlet = FigletBuilder::new()
.font(Font::Standard)
.build()
.expect("build");
let banner = figlet.render("Hi").expect("render");
assert!(banner.height() >= 1);Implementations§
Source§impl Figlet
impl Figlet
Sourcepub fn render(&self, text: &str) -> Result<Banner, FigletError>
pub fn render(&self, text: &str) -> Result<Banner, FigletError>
Render text into a Banner.
The returned banner exposes a lazy line iterator (per FR-053): row
buffers are precomputed once during render(), and Banner::lines
yields one row per next() without copying the whole banner.
Sourcepub fn from_tlf(path: impl AsRef<Path>) -> Result<Figlet, FigletError>
Available on crate feature tlf-parser only.
pub fn from_tlf(path: impl AsRef<Path>) -> Result<Figlet, FigletError>
tlf-parser only.Load a .tlf font from disk and return a renderable Figlet.
Bounded per spec Edge Cases: zero-byte files, files larger than 8 MiB, and symlink loops are rejected before allocation.
Returns FigletError::InvalidTlfHeader when the magic prefix
mismatches, FigletError::TlfParse for later parse failures.
Gated by the tlf-parser Cargo leaf.
Sourcepub fn from_tlf_bytes(bytes: &[u8]) -> Result<Figlet, FigletError>
Available on crate feature tlf-parser only.
pub fn from_tlf_bytes(bytes: &[u8]) -> Result<Figlet, FigletError>
tlf-parser only.Build a Figlet from raw .tlf bytes (no filesystem access).
Mirrors Figlet::from_tlf but skips the disk-bounded I/O checks.
Bytes larger than 8 MiB still trigger FigletError::TlfParse.
Gated by the tlf-parser Cargo leaf.
Sourcepub fn color_depth(&self) -> ColorDepth
pub fn color_depth(&self) -> ColorDepth
Cached color depth in use by this renderer (E012 US4 — AD-003).
Set at builder time via FigletBuilder::color_depth (or
auto-detected via ColorDepth::detect when unset) and cached
onto the renderer for the lifetime of this instance per FR-031.
The render path NEVER re-probes the terminal — invalidation is
caller-driven only via Figlet::set_color_depth.
Sourcepub fn set_color_depth(&mut self, depth: ColorDepth)
pub fn set_color_depth(&mut self, depth: ColorDepth)
Invalidate the cached color depth (E012 US4 — AD-003 + FR-031).
Replaces the cached value; subsequent renders observe the new
depth. Callers who wish to re-detect the terminal capability
should pass ColorDepth::detect.
This is the only documented way to invalidate the cache — the render path itself never re-probes per FR-031. Calling this method does not allocate.