fix: use extreme style values (14/20/26 font), remove RichText::line_height, fix para spacing threshold
This commit is contained in:
@@ -55,8 +55,7 @@ pub fn reading_view(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let panel_size = ui.available_size();
|
let panel_size = ui.available_size();
|
||||||
let line_h = style.line_height();
|
recalculate_pages(book, style.font_size, style.line_height(), panel_size.x, panel_size.y);
|
||||||
recalculate_pages(book, style.font_size, line_h, panel_size.x, panel_size.y);
|
|
||||||
|
|
||||||
let colors = theme::reader_colors(theme);
|
let colors = theme::reader_colors(theme);
|
||||||
|
|
||||||
@@ -220,7 +219,6 @@ pub fn reading_view(
|
|||||||
egui::Label::new(
|
egui::Label::new(
|
||||||
egui::RichText::new(&indented)
|
egui::RichText::new(&indented)
|
||||||
.size(style.font_size)
|
.size(style.font_size)
|
||||||
.line_height(Some(style.line_height()))
|
|
||||||
.color(colors.text)
|
.color(colors.text)
|
||||||
).wrap()
|
).wrap()
|
||||||
);
|
);
|
||||||
|
|||||||
24
src/style.rs
24
src/style.rs
@@ -31,24 +31,24 @@ impl StyleProfile {
|
|||||||
StyleProfile {
|
StyleProfile {
|
||||||
name: "紧凑".into(),
|
name: "紧凑".into(),
|
||||||
alignment: TextAlignment::Left,
|
alignment: TextAlignment::Left,
|
||||||
line_spacing: 1.2,
|
line_spacing: 1.0,
|
||||||
paragraph_spacing: 0.3,
|
paragraph_spacing: 0.0,
|
||||||
first_line_indent: 2.0,
|
first_line_indent: 0.0,
|
||||||
font_size: 16.0,
|
font_size: 14.0,
|
||||||
},
|
},
|
||||||
StyleProfile {
|
StyleProfile {
|
||||||
name: "宽松".into(),
|
name: "宽松".into(),
|
||||||
alignment: TextAlignment::Left,
|
alignment: TextAlignment::Left,
|
||||||
line_spacing: 2.4,
|
line_spacing: 1.0,
|
||||||
paragraph_spacing: 1.8,
|
paragraph_spacing: 3.0,
|
||||||
first_line_indent: 2.0,
|
first_line_indent: 2.0,
|
||||||
font_size: 24.0,
|
font_size: 26.0,
|
||||||
},
|
},
|
||||||
StyleProfile {
|
StyleProfile {
|
||||||
name: "居中".into(),
|
name: "居中".into(),
|
||||||
alignment: TextAlignment::Center,
|
alignment: TextAlignment::Center,
|
||||||
line_spacing: 1.6,
|
line_spacing: 1.0,
|
||||||
paragraph_spacing: 1.0,
|
paragraph_spacing: 0.0,
|
||||||
first_line_indent: 0.0,
|
first_line_indent: 0.0,
|
||||||
font_size: 20.0,
|
font_size: 20.0,
|
||||||
},
|
},
|
||||||
@@ -67,11 +67,11 @@ impl StyleProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn apply_para_spacing(text: &str, spacing: f32) -> String {
|
fn apply_para_spacing(text: &str, spacing: f32) -> String {
|
||||||
if spacing <= 0.5 {
|
if spacing <= 0.0 {
|
||||||
return text.to_string();
|
return text.to_string();
|
||||||
}
|
}
|
||||||
// Each unit of paragraph_spacing adds one extra blank line
|
// Each unit of spacing adds one empty line between paragraphs
|
||||||
let extra_nls = (spacing * 2.0).round() as usize;
|
let extra_nls = (spacing * 2.0).round() as usize + 2; // minimum 2 newlines (1 empty line)
|
||||||
let sep = "\n".repeat(extra_nls);
|
let sep = "\n".repeat(extra_nls);
|
||||||
text.replace("\n\n", &sep)
|
text.replace("\n\n", &sep)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user