Crates.io | multi-mono-font |
lib.rs | multi-mono-font |
version | 0.3.2 |
source | src |
created_at | 2024-09-04 12:58:23.177718 |
updated_at | 2024-09-28 13:53:42.090405 |
description | Multi mono font mixed typesetting for embedded-graphics |
homepage | |
repository | https://github.com/Merisy-Thing/multi-mono-font |
max_upload_size | |
id | 1363307 |
size | 9,525,998 |
Multi mono font mixed typesetting for embedded-graphics
This crate is modified based on embedded-graphics MonoFonts to add support for displaying different sizes of monospaced fonts within the same line/segment of text.
The strikethrough and underline have been removed from the original fonts, and some variable types have been changed to u8 (can be changed to u16 via features) to save storage space.
Check examples/mono.rs for usage.
const MULTI_STYLE: MultiMonoTextStyle<Rgb565> = MultiMonoTextStyle::new(
&[&UPPER_FONT, &HZ_FONT, &LOWER_FONT],
MultiMonoLineHeight::Max,
Rgb565::WHITE,
);
let _next = Text::new("测HElLo试OK\n", Point::new(0, 32), MULTI_STYLE)
.draw(&mut disp)
.unwrap();
let _next = Text::new("字WoRlD体ok", _next, MULTI_STYLE)
.draw(&mut disp)
.unwrap();
let rect = Rectangle::new(Point::new(52, 20), Size::new(64, 24));
StaticText::with_style(
"HE字LL",
rect,
MULTI_STYLE,
Alignment::Center,
Baseline::Alphabetic,
)
.draw(&mut disp)
.unwrap();
rect.into_styled(RECT_STYLE).draw(&mut disp).unwrap();