fix(style): fix paragraph spacing formula, reduce from 2x to linear extra lines
This commit is contained in:
@@ -40,7 +40,7 @@ impl StyleProfile {
|
||||
name: "宽松".into(),
|
||||
alignment: TextAlignment::Left,
|
||||
line_spacing: 1.0,
|
||||
paragraph_spacing: 3.0,
|
||||
paragraph_spacing: 1.0,
|
||||
first_line_indent: 2.0,
|
||||
font_size: 26.0,
|
||||
},
|
||||
@@ -70,9 +70,9 @@ fn apply_para_spacing(text: &str, spacing: f32) -> String {
|
||||
if spacing <= 0.0 {
|
||||
return text.to_string();
|
||||
}
|
||||
// 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);
|
||||
// spacing 表示额外空白行数:基础换行 \n\n 已有1行空白,再加 spacing 行
|
||||
let newlines = 2 + spacing.round().max(0.0) as usize;
|
||||
let sep = "\n".repeat(newlines);
|
||||
text.replace("\n\n", &sep)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user