From fe3abd83d7206a6ff8cb1980ab3f7b48e9a3aa03 Mon Sep 17 00:00:00 2001 From: Valentin Weber Date: Fri, 21 Feb 2025 22:28:40 +0100 Subject: [PATCH] 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. --- Cargo.lock | 11 +++++++++++ Cargo.toml | 3 ++- LICENSE-MIT | 2 +- src/main.rs | 7 ++++--- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 918d53b..f096b85 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -125,6 +125,7 @@ dependencies = [ "time", "tokio", "toml", + "u8g2-fonts", "uuid", "zerocopy", ] @@ -1038,6 +1039,16 @@ dependencies = [ "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]] name = "unicode-ident" version = "1.0.12" diff --git a/Cargo.toml b/Cargo.toml index 86272cd..6b7aa58 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "badgemagic" version = "0.1.0" -authors = ["Martin Michaelis "] +authors = ["Martin Michaelis ", "Valentin Weber "] edition = "2021" description = "Badge Magic with LEDs - Library and CLI" homepage = "https://badgemagic.fossasia.org" @@ -50,3 +50,4 @@ serde_json = { version = "1.0.134", optional = true } time = "0.3.37" toml = { version = "0.8.19", optional = true } zerocopy = { version = "0.8.14", features = ["derive"] } +u8g2-fonts = { version = "0.5.2", features = ["embedded_graphics_textstyle"] } diff --git a/LICENSE-MIT b/LICENSE-MIT index dd968bb..f98b5e9 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -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 of this software and associated documentation files (the “Software”), to deal diff --git a/src/main.rs b/src/main.rs index fcbe5ff..f9be51e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,12 +13,12 @@ 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, }; use serde::Deserialize; +use u8g2_fonts::{fonts::u8g2_font_lucasfont_alternate_tf, U8g2TextStyle}; #[derive(Parser)] /// Upload a configuration with up to 8 messages to an LED badge @@ -161,9 +161,10 @@ 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); } Content::Bitstring { bitstring } => {