feat: Move 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-02-21 22:28:40 +01:00
parent ce7d12fc58
commit fe3abd83d7
No known key found for this signature in database
GPG key ID: 44797000F143F522
4 changed files with 18 additions and 5 deletions

11
Cargo.lock generated
View file

@ -125,6 +125,7 @@ dependencies = [
"time", "time",
"tokio", "tokio",
"toml", "toml",
"u8g2-fonts",
"uuid", "uuid",
"zerocopy", "zerocopy",
] ]
@ -1038,6 +1039,16 @@ dependencies = [
"winnow", "winnow",
] ]
[[package]]
name = "u8g2-fonts"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "132e15484caa39440cc9d6317c1f1980a13259234e630db2270ea2a2b1e5c4a2"
dependencies = [
"embedded-graphics",
"embedded-graphics-core",
]
[[package]] [[package]]
name = "unicode-ident" name = "unicode-ident"
version = "1.0.12" version = "1.0.12"

View file

@ -1,7 +1,7 @@
[package] [package]
name = "badgemagic" name = "badgemagic"
version = "0.1.0" version = "0.1.0"
authors = ["Martin Michaelis <code@mgjm.de>"] authors = ["Martin Michaelis <code@mgjm.de>", "Valentin Weber <weva+code@kabelsalat.ch>"]
edition = "2021" edition = "2021"
description = "Badge Magic with LEDs - Library and CLI" description = "Badge Magic with LEDs - Library and CLI"
homepage = "https://badgemagic.fossasia.org" homepage = "https://badgemagic.fossasia.org"
@ -50,3 +50,4 @@ serde_json = { version = "1.0.134", optional = true }
time = "0.3.37" time = "0.3.37"
toml = { version = "0.8.19", optional = true } toml = { version = "0.8.19", optional = true }
zerocopy = { version = "0.8.14", features = ["derive"] } zerocopy = { version = "0.8.14", features = ["derive"] }
u8g2-fonts = { version = "0.5.2", features = ["embedded_graphics_textstyle"] }

View file

@ -1,4 +1,4 @@
Copyright 2024 Martin Michaelis Copyright 2024 Martin Michaelis, Valentin Weber
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal of this software and associated documentation files (the “Software”), to deal

View file

@ -13,12 +13,12 @@ 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};
#[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
@ -161,9 +161,10 @@ 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);
} }
Content::Bitstring { bitstring } => { Content::Bitstring { bitstring } => {