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:
Valentin Weber 2025-07-19 16:28:11 +02:00
parent 5d745ab8fd
commit 32abfae4f3
No known key found for this signature in database
GPG key ID: 44797000F143F522
2 changed files with 12 additions and 9 deletions

View file

@ -50,3 +50,4 @@ serde_json = { version = "1.0.140", optional = true }
time = "0.3.41" time = "0.3.41"
toml = { version = "0.9.2", optional = true } toml = { version = "0.9.2", optional = true }
zerocopy = { version = "0.8.26", features = ["derive"] } zerocopy = { version = "0.8.26", features = ["derive"] }
u8g2-fonts = { version = "0.7.1", features = ["embedded_graphics_textstyle"] }

View file

@ -4,22 +4,24 @@
use std::{fs, path::PathBuf}; use std::{fs, path::PathBuf};
use anyhow::{Context, Result}; use anyhow::{Context, Result};
use badgemagic::{
ble::Device as BleDevice,
protocol::{Mode, PayloadBuffer, Speed, Style},
usb_hid::Device as UsbDevice,
};
use base64::Engine; use base64::Engine;
use clap::{Parser, ValueEnum}; use clap::{Parser, ValueEnum};
use embedded_graphics::{ use embedded_graphics::{
geometry::Point, geometry::Point,
image::{Image, ImageRawLE}, image::{Image, ImageRawLE},
mono_font::{iso_8859_1::FONT_6X9, MonoTextStyle},
pixelcolor::BinaryColor, pixelcolor::BinaryColor,
text::Text, text::Text,
Drawable, Pixel, Drawable,
Pixel,
}; };
use serde::Deserialize; 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)] #[derive(Parser)]
/// Upload a configuration with up to 8 messages to an LED badge /// 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 } => { Content::Text { text } => {
let text = Text::new( let text = Text::new(
&text, &text,
Point::new(0, 7), Point::new(0, 8),
MonoTextStyle::new(&FONT_6X9, BinaryColor::On), U8g2TextStyle::new(u8g2_font_lucasfont_alternate_tf, BinaryColor::On),
); );
payload.add_message_drawable(style, &text); payload.add_message_drawable(style, &text);
} }