From 32abfae4f3f20b27531d57ea9a3875bef5498e87 Mon Sep 17 00:00:00 2001 From: Valentin Weber Date: Sat, 19 Jul 2025 16:28:11 +0200 Subject: [PATCH] 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. --- Cargo.toml | 1 + src/main.rs | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 84c9310..fce0ba2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] } \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 116a66c..201e2b6 100644 --- a/src/main.rs +++ b/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 { 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); }