From 0521439281bf829cdc5b33f681d8642b93ceaf3f Mon Sep 17 00:00:00 2001 From: Developer Date: Thu, 14 May 2026 21:19:15 +0800 Subject: [PATCH] fix: use extreme style values (14/20/26 font), remove RichText::line_height, fix para spacing threshold --- src/reader.rs | 4 +--- src/style.rs | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/reader.rs b/src/reader.rs index ce06281..04ec06c 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -55,8 +55,7 @@ pub fn reading_view( }; let panel_size = ui.available_size(); - let line_h = style.line_height(); - recalculate_pages(book, style.font_size, line_h, panel_size.x, panel_size.y); + recalculate_pages(book, style.font_size, style.line_height(), panel_size.x, panel_size.y); let colors = theme::reader_colors(theme); @@ -220,7 +219,6 @@ pub fn reading_view( egui::Label::new( egui::RichText::new(&indented) .size(style.font_size) - .line_height(Some(style.line_height())) .color(colors.text) ).wrap() ); diff --git a/src/style.rs b/src/style.rs index 9ffe463..10e7de7 100644 --- a/src/style.rs +++ b/src/style.rs @@ -31,24 +31,24 @@ impl StyleProfile { StyleProfile { name: "紧凑".into(), alignment: TextAlignment::Left, - line_spacing: 1.2, - paragraph_spacing: 0.3, - first_line_indent: 2.0, - font_size: 16.0, + line_spacing: 1.0, + paragraph_spacing: 0.0, + first_line_indent: 0.0, + font_size: 14.0, }, StyleProfile { name: "宽松".into(), alignment: TextAlignment::Left, - line_spacing: 2.4, - paragraph_spacing: 1.8, + line_spacing: 1.0, + paragraph_spacing: 3.0, first_line_indent: 2.0, - font_size: 24.0, + font_size: 26.0, }, StyleProfile { name: "居中".into(), alignment: TextAlignment::Center, - line_spacing: 1.6, - paragraph_spacing: 1.0, + line_spacing: 1.0, + paragraph_spacing: 0.0, first_line_indent: 0.0, font_size: 20.0, }, @@ -67,11 +67,11 @@ impl StyleProfile { } fn apply_para_spacing(text: &str, spacing: f32) -> String { - if spacing <= 0.5 { + if spacing <= 0.0 { return text.to_string(); } - // Each unit of paragraph_spacing adds one extra blank line - let extra_nls = (spacing * 2.0).round() as usize; + // Each unit of spacing adds one empty line between paragraphs + let extra_nls = (spacing * 2.0).round() as usize + 2; // minimum 2 newlines (1 empty line) let sep = "\n".repeat(extra_nls); text.replace("\n\n", &sep) }