use crate::model::{control::Equation, table::Table};
pub(super) fn from_box(table: Table, baseline_1800dpi: u16) -> Equation {
let mut script = String::new();
if let Some(cell) = table.cells.first() {
for paragraph in &cell.paragraphs {
script.push_str(¶graph.text);
script.push('\n');
}
}
let baseline_hu = u64::from(baseline_1800dpi) * 4;
let height = u64::from(table.common.height);
let baseline = if height > 0 && baseline_hu <= height {
((baseline_hu * 100 + height / 2) / height) as i16
} else {
0
};
Equation {
common: table.common,
script: script.trim().to_owned(),
font_size: 1200,
font_name: "HYhwpEQ".to_owned(),
baseline,
..Default::default()
}
}