pub struct Font { /* private fields */ }Expand description
A font that can be used to render text as ASCII art.
Fonts can be loaded from FIGlet font files (.flf) or created as plain text.
Multiple fonts can be combined into a stack for automatic fallback rendering.
§Examples
use artbox::Font;
// Load from embedded fonts
let font = artbox::fonts::font("slant").unwrap();
// Create a plain text font (no ASCII art)
let plain = Font::plain();Implementations§
Source§impl Font
impl Font
Sourcepub fn figlet(font: FIGfont) -> Self
pub fn figlet(font: FIGfont) -> Self
Creates a font from a parsed FIGfont.
This is a low-level constructor. Prefer Font::from_file, Font::from_content,
or the fonts module for loading fonts.
Sourcepub fn from_content(contents: &str) -> Result<Self, FontError>
pub fn from_content(contents: &str) -> Result<Self, FontError>
Creates a font from FIGlet font content as a string.
§Errors
Returns an error if the content is not valid FIGlet format.
Sourcepub fn from_bytes_latin1(bytes: &[u8]) -> Result<Self, FontError>
pub fn from_bytes_latin1(bytes: &[u8]) -> Result<Self, FontError>
Creates a font from raw bytes encoded as Latin-1.
This is useful for loading embedded font data. Each byte is interpreted as a Latin-1 character code point.
§Errors
Returns an error if the content is not valid FIGlet format.
Sourcepub fn from_bytes_utf8(bytes: &[u8]) -> Result<Self, FontError>
pub fn from_bytes_utf8(bytes: &[u8]) -> Result<Self, FontError>
Creates a font from raw bytes encoded as UTF-8.
Use this for fonts containing Unicode characters like block elements (█▀▄).
§Errors
Returns an error if the bytes are not valid UTF-8 or valid FIGlet format.