tweak(pagination): safety_h=1.0 to reduce underfill

This commit is contained in:
Developer
2026-05-15 23:35:50 +08:00
parent 006cb3cd5e
commit 4add295bfa
2 changed files with 1 additions and 3 deletions

View File

@@ -6,7 +6,7 @@ use crate::theme::{self, BgType, Theme};
pub fn recalculate_pages(book: &mut Book, font_size: f32, line_height: f32, panel_width: f32, panel_height: f32, style: &StyleProfile) { pub fn recalculate_pages(book: &mut Book, font_size: f32, line_height: f32, panel_width: f32, panel_height: f32, style: &StyleProfile) {
let char_width = font_size * 1.0; let char_width = font_size * 1.0;
let safety_w = 0.95; let safety_w = 0.95;
let safety_h = 0.96; let safety_h = 1.0;
let chars_per_line = if char_width > 0.0 { let chars_per_line = if char_width > 0.0 {
((panel_width / char_width) * safety_w).max(1.0) as usize ((panel_width / char_width) * safety_w).max(1.0) as usize
} else { } else {

View File

@@ -56,8 +56,6 @@ impl StyleProfile {
} }
pub fn line_height(&self) -> f32 { pub fn line_height(&self) -> f32 {
// egui actual line height is approximately font_size * 1.1
// line_spacing adds extra (line_spacing - 1.0) * font_size * 0.5 as extra gap
self.font_size * 1.1 + self.font_size * (self.line_spacing - 1.0).max(0.0) * 0.5 self.font_size * 1.1 + self.font_size * (self.line_spacing - 1.0).max(0.0) * 0.5
} }