Skip to content

Commit

Permalink
Allow configuration of font size
Browse files Browse the repository at this point in the history
  • Loading branch information
tarkah committed Jun 26, 2023
1 parent 97e8434 commit 3212113
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ font:
# Specify the monospaced font family to use
# - Default is Iosevka Term and provided by this application
family: Iosevka Term
# Specify the font size
# - Default is 13
size: 13

# Settings applied by default to new buffers
new_buffer:
Expand Down
1 change: 1 addition & 0 deletions data/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub struct Config {
#[derive(Debug, Clone, Default, Deserialize)]
pub struct Font {
pub family: Option<String>,
pub size: Option<u8>,
// TODO: Do we make size, etc configurable and pass to Theme?
}

Expand Down
9 changes: 8 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,16 @@ fn window_settings() -> iced::window::Settings {
fn settings(
config_load: Result<Config, config::Error>,
) -> iced::Settings<Result<Config, config::Error>> {
let default_text_size = config_load
.as_ref()
.ok()
.and_then(|config| config.font.size)
.map(f32::from)
.unwrap_or(theme::TEXT_SIZE);

iced::Settings {
default_font: font::MONO.clone().into(),
default_text_size: theme::TEXT_SIZE,
default_text_size,
window: iced::window::Settings {
..window_settings()
},
Expand Down
2 changes: 2 additions & 0 deletions src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use iced::{application, Background, Color};

use crate::widget::selectable_text;

// TODO: If we use non-standard font sizes, we should consider
// Config.font.size since it's user configurable
pub const TEXT_SIZE: f32 = 13.0;
pub const ICON_SIZE: f32 = 12.0;

Expand Down

0 comments on commit 3212113

Please sign in to comment.