Skip to content

Commit 957c08a

Browse files
committed
configure line-height from config, fixes #15.
1 parent 99adafb commit 957c08a

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

overlay-config.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@ background_color = "#32373C"
1717
text_color = "#ffffff"
1818

1919
# Font size in pixels
20-
# Default: 10.0
20+
# Default: 12.0
2121
# Recommended range: 10-13
22-
font_size = 10.0
22+
font_size = 13.0
23+
24+
## Line height multiply in pixels
25+
## Default: 1.7
26+
### Recommended range: 1.5-3.0
27+
line_height = 1.7
2328

2429
# Enable/disable blur effect for frosted glass appearance
25-
# Default: true
26-
apply-blur = true
30+
# Default: false
31+
apply-blur = false
2732

2833
# Overlay anchor position
2934
# Default: "center"

src/config.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ pub struct OverlayConfig {
1818
#[serde(default = "default_font_size")]
1919
pub font_size: f32,
2020

21+
/// Line height in pixels
22+
#[serde(default = "default_line_height")]
23+
pub line_height: f32,
24+
2125
/// Whether to apply blur effect to the background
2226
#[serde(default = "default_apply_blur", rename = "apply-blur")]
2327
pub apply_blur: bool,
@@ -45,6 +49,7 @@ impl Default for OverlayConfig {
4549
background_color: default_background_color(),
4650
text_color: default_text_color(),
4751
font_size: default_font_size(),
52+
line_height: default_line_height(),
4853
apply_blur: default_apply_blur(),
4954
anchor: default_anchor(),
5055
width: default_width(),
@@ -67,6 +72,10 @@ fn default_font_size() -> f32 {
6772
12.0
6873
}
6974

75+
fn default_line_height() -> f32 {
76+
1.5
77+
}
78+
7079
fn default_apply_blur() -> bool {
7180
true
7281
}

src/overlay.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ impl OverlayApp {
404404
// We'll create a Buffer for each logical line, shape it, then use its
405405
// draw callback to composite glyph pixels into the canvas.
406406
let font_size: f32 = self.config.font_size;
407-
let line_height: f32 = font_size * 3.0; // Further increased to prevent overlap with wrapped text
407+
let line_height: f32 = font_size * self.config.line_height; // Further increased to prevent overlap with wrapped text
408408
let metrics = Metrics::new(font_size, line_height);
409409

410410
// Padding for text area

0 commit comments

Comments
 (0)