diff --git a/justfile b/justfile index 664e52b3..6c9a7580 100644 --- a/justfile +++ b/justfile @@ -44,7 +44,7 @@ docgen: Get-ChildItem -Path "docs/cli" -Recurse -File | ForEach-Object { (Get-Content $_.FullName) -replace 'Usage: ', 'Usage: komorebic.exe ' | Set-Content $_.FullName } schemagen: - komorebic static-config-schema > schema.json - komorebic application-specific-configuration-schema > schema.asc.json - komorebi-bar --schema > schema.bar.json + cargo run --package komorebic -- static-config-schema > schema.json + cargo run --package komorebic -- application-specific-configuration-schema > schema.asc.json + cargo run --package komorebi-bar -- --schema > schema.bar.json generate-schema-doc .\schema.json --config template_name=js_offline --config minify=false .\static-config-docs\ diff --git a/komorebi-bar/src/bar.rs b/komorebi-bar/src/bar.rs index 7bba98ad..e31f9df5 100644 --- a/komorebi-bar/src/bar.rs +++ b/komorebi-bar/src/bar.rs @@ -12,10 +12,12 @@ use eframe::egui::Context; use eframe::egui::FontData; use eframe::egui::FontDefinitions; use eframe::egui::FontFamily; +use eframe::egui::FontId; use eframe::egui::Frame; use eframe::egui::Layout; use eframe::egui::Margin; use eframe::egui::Style; +use eframe::egui::TextStyle; use eframe::egui::Vec2; use eframe::egui::ViewportCommand; use font_loader::system_fonts; @@ -176,6 +178,11 @@ impl Komobar { } } + if let Some(font_size) = &config.font_size { + tracing::info!("attempting to set custom font size: {font_size}"); + Self::set_font_size(ctx, *font_size); + } + let mut komorebi_widget = None; let mut komorebi_widget_idx = None; let mut komorebi_notification_state = previous_notification_state; @@ -263,6 +270,31 @@ impl Komobar { komobar } + fn set_font_size(ctx: &Context, font_size: f32) { + ctx.style_mut(|style| { + style.text_styles = [ + (TextStyle::Small, FontId::new(9.0, FontFamily::Proportional)), + ( + TextStyle::Body, + FontId::new(font_size, FontFamily::Proportional), + ), + ( + TextStyle::Button, + FontId::new(font_size, FontFamily::Proportional), + ), + ( + TextStyle::Heading, + FontId::new(18.0, FontFamily::Proportional), + ), + ( + TextStyle::Monospace, + FontId::new(font_size, FontFamily::Monospace), + ), + ] + .into(); + }); + } + fn add_custom_font(ctx: &Context, name: &str) { let mut fonts = FontDefinitions::default(); egui_phosphor::add_to_fonts(&mut fonts, egui_phosphor::Variant::Regular); diff --git a/komorebi-bar/src/config.rs b/komorebi-bar/src/config.rs index ff75020c..07ff5be0 100644 --- a/komorebi-bar/src/config.rs +++ b/komorebi-bar/src/config.rs @@ -19,6 +19,8 @@ pub struct KomobarConfig { pub monitor: MonitorConfig, /// Font family pub font_family: Option, + /// Font size (default: 12.5) + pub font_size: Option, /// Theme pub theme: Option, /// Left side widgets (ordered left-to-right) diff --git a/schema.bar.json b/schema.bar.json index cfa6d074..2b97bcc3 100644 --- a/schema.bar.json +++ b/schema.bar.json @@ -12,6 +12,11 @@ "description": "Font family", "type": "string" }, + "font_size": { + "description": "Font size (default: 12.5)", + "type": "number", + "format": "float" + }, "frame": { "description": "Frame options (see: https://docs.rs/egui/latest/egui/containers/struct.Frame.html)", "type": "object",