Crate unicode_font
source ·Expand description
Unicode font conversion.
Characters with font variants encoded in Unicode have a best-effort chosen plain
variant.
Plain
unicodes can be converted to different font variants using this crate.
Most of the conversions use mathematical characters.
See Variant
for the font variants included.
Examples
Transform a character to a few fonts.
assert_eq!(unicode_font::try_as_bold(&'a'), Some(&'\u{1D41A}')); // 𝐚
assert_eq!(unicode_font::try_as_circled(&'a'), Some(&'\u{24D0}')); // ⓐ
assert_eq!(unicode_font::try_as_monospace(&'a'), Some(&'\u{1D68A}')); // 𝚊
assert_eq!(unicode_font::try_as_small_capital(&'a'), None);
assert_eq!(unicode_font::try_as_small_capital(&'A'), Some(&'\u{1D00}')); // ᴀ
assert_eq!(unicode_font::try_as_squared(&'a'), None);
assert_eq!(unicode_font::try_as_squared(&'A'), Some(&'\u{1F130}')); // 🄰
Transform a &str
if all characters transform.
fn as_bold(s: &str) -> Option<String> {
s.chars().map(|c| unicode_font::try_as_bold(&c).cloned()).collect()
}
assert_eq!(as_bold("abc"), Some(String::from("𝐚𝐛𝐜")));
Re-exports
pub use crate::arabic_mathematical::try_as_arabic_mathematical;
pub use crate::bold::try_as_bold;
pub use crate::bold_italic::try_as_bold_italic;
pub use crate::bold_fraktur::try_as_bold_fraktur;
pub use crate::bold_script::try_as_bold_script;
pub use crate::circled::try_as_circled;
pub use crate::comma::try_as_comma;
pub use crate::double_struck::try_as_double_struck;
pub use crate::fraktur::try_as_fraktur;
pub use crate::full_stop::try_as_full_stop;
pub use crate::fullwidth::try_as_fullwidth;
pub use crate::italic::try_as_italic;
pub use crate::looped::try_as_looped;
pub use crate::monospace::try_as_monospace;
pub use crate::negative_circled::try_as_negative_circled;
pub use crate::negative_squared::try_as_negative_squared;
pub use crate::regional::try_as_regional;
pub use crate::segmented::try_as_segmented;
pub use crate::other::try_as_other;
pub use crate::parenthesized::try_as_parenthesized;
pub use crate::sans_serif_bold_italic::try_as_sans_serif_bold_italic;
pub use crate::sans_serif_bold::try_as_sans_serif_bold;
pub use crate::sans_serif_italic::try_as_sans_serif_italic;
pub use crate::sans_serif::try_as_sans_serif;
pub use crate::script::try_as_script;
pub use crate::small_capital::try_as_small_capital;
pub use crate::superscript::try_as_superscript;
pub use crate::subscript::try_as_subscript;
pub use crate::stretched::try_as_stretched;
pub use crate::squared::try_as_squared;
pub use crate::tailed::try_as_tailed;
pub use crate::wide::try_as_wide;
pub use variant::Variant;
pub use plain::try_as_plain;
Modules
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Plain variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Variant of Unicode symbols.
- Font variants.
- Variant of Unicode symbols.