mirror of
https://github.com/fossasia/badgemagic-rs
synced 2025-08-14 11:17:59 +00:00
feat: switch to proportional font
To use the available space on the bade more efficient, I changed the font to u8g2_font_lucasfont_alternate_tf from [u8g2-fonts](https://docs.rs/crate/u8g2-fonts/). Lucasfont Alternate was created by Patrick Lauke and is licensed under [CC BY 3.0](https://creativecommons.org/licenses/by/3.0/). No changes to the font were made.
This commit is contained in:
parent
5d745ab8fd
commit
32abfae4f3
2 changed files with 12 additions and 9 deletions
|
@ -50,3 +50,4 @@ serde_json = { version = "1.0.140", optional = true }
|
|||
time = "0.3.41"
|
||||
toml = { version = "0.9.2", optional = true }
|
||||
zerocopy = { version = "0.8.26", features = ["derive"] }
|
||||
u8g2-fonts = { version = "0.7.1", features = ["embedded_graphics_textstyle"] }
|
20
src/main.rs
20
src/main.rs
|
@ -4,22 +4,24 @@
|
|||
use std::{fs, path::PathBuf};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use badgemagic::{
|
||||
ble::Device as BleDevice,
|
||||
protocol::{Mode, PayloadBuffer, Speed, Style},
|
||||
usb_hid::Device as UsbDevice,
|
||||
};
|
||||
use base64::Engine;
|
||||
use clap::{Parser, ValueEnum};
|
||||
use embedded_graphics::{
|
||||
geometry::Point,
|
||||
image::{Image, ImageRawLE},
|
||||
mono_font::{iso_8859_1::FONT_6X9, MonoTextStyle},
|
||||
pixelcolor::BinaryColor,
|
||||
text::Text,
|
||||
Drawable, Pixel,
|
||||
Drawable,
|
||||
Pixel,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use u8g2_fonts::{fonts::u8g2_font_lucasfont_alternate_tf, U8g2TextStyle};
|
||||
|
||||
use badgemagic::{
|
||||
ble::Device as BleDevice,
|
||||
protocol::{Mode, PayloadBuffer, Speed, Style},
|
||||
usb_hid::Device as UsbDevice,
|
||||
};
|
||||
|
||||
#[derive(Parser)]
|
||||
/// Upload a configuration with up to 8 messages to an LED badge
|
||||
|
@ -162,8 +164,8 @@ fn gnerate_payload(args: &mut Args) -> Result<PayloadBuffer> {
|
|||
Content::Text { text } => {
|
||||
let text = Text::new(
|
||||
&text,
|
||||
Point::new(0, 7),
|
||||
MonoTextStyle::new(&FONT_6X9, BinaryColor::On),
|
||||
Point::new(0, 8),
|
||||
U8g2TextStyle::new(u8g2_font_lucasfont_alternate_tf, BinaryColor::On),
|
||||
);
|
||||
payload.add_message_drawable(style, &text);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue