mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-29 05:06:51 -06:00
Rows: a big font isn't counted twice when the sheet's default height already fits it
auto_row_height estimated a line of a bigger font by scaling the sheet's default row height by size / 11. When the sheet's default already fits that font, the font counted twice: Excel for Mac saves rows of 16pt text with defaultRowHeight="21" (28px) and no ht, and opening such a file fitted every row to 40.7px, 1.45 times Excel's height. Rows mixing Middle and Bottom aligned cells then looked misaligned. The estimate now scales an 11pt row's height (DEFAULT_ROW_HEIGHT), so those rows open at 29px, and rows on a 15pt-default sheet still grow to their font (#833). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f1894c6da6
commit
2a9f40c65e
@@ -484,7 +484,9 @@ pub fn auto_row_height(wb: &mut Workbook, si: usize, row: u32) {
|
||||
for (c, cell) in sh.cells.row(row, 0, gridcraft_core::MAX_COLS - 1) {
|
||||
let st = wb.styles.get(cell.style);
|
||||
let size = st.font.size;
|
||||
let line = (size * 1.8).round().max(default * size / gridcraft_model::DEFAULT_FONT_SIZE);
|
||||
// Scaled from an 11pt row's height, not the sheet's default: a sheet whose default
|
||||
// already fits a bigger font (21pt rows for 16pt text) would otherwise scale it twice.
|
||||
let line = (size * 1.8).round().max(gridcraft_model::DEFAULT_ROW_HEIGHT * size / gridcraft_model::DEFAULT_FONT_SIZE);
|
||||
let mut lines = 1.0f32;
|
||||
if !cell.value.is_empty() || cell.formula.is_some() {
|
||||
let text = crate::display::cell_text(wb, sh, CellRef::new(row, c));
|
||||
|
||||
Reference in New Issue
Block a user