Use CMR10 advances for route-D paragraphs and PDF text
This commit is contained in:
1 parent
8251e35de2
commit
67915402a6
7 files changed
+45
-19
No files matched your search
@@ -461,7 +461,8 @@ impl Unit {
|
||||
style: ParagraphStyle,
|
||||
) -> Self {
|
||||
let source = source.into();
|
||||
let paragraph = layout_paragraph(&source, &style);
|
||||
let paragraph =
|
||||
layout_paragraph_with_font(&source, &style, &crate::cmr10::Cmr10Metrics::new());
|
||||
Self {
|
||||
id,
|
||||
source,
|
||||
@@ -1353,15 +1354,16 @@ mod tests {
|
||||
let mut document = Document::new(
|
||||
100,
|
||||
vec![
|
||||
Unit::paragraph(1, "a ".repeat(200)),
|
||||
Unit::paragraph(2, "b ".repeat(200)),
|
||||
Unit::paragraph(1, "a ".repeat(20)),
|
||||
Unit::vertical(2, vec![VerticalItem::Penalty(-10_000)]),
|
||||
Unit::paragraph(3, "b ".repeat(200)),
|
||||
],
|
||||
);
|
||||
let mut engine = Engine::layout(&document);
|
||||
let before = engine.pages()[0].hash;
|
||||
engine.edit(&document, 2, "c ".repeat(200));
|
||||
engine.edit(&document, 3, "c ".repeat(200));
|
||||
assert_eq!(engine.pages()[0].hash, before);
|
||||
document.units[1].source = "c ".repeat(200);
|
||||
document.units[2].source = "c ".repeat(200);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1598,6 +1600,21 @@ mod tests {
|
||||
assert_eq!(before, after);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn paragraph_widths_come_from_cmr10_not_fixed_cells() {
|
||||
let width = |source: &str| {
|
||||
let unit = Unit::paragraph(1, source);
|
||||
match &unit.items[0] {
|
||||
VerticalItem::Paragraph(paragraph) => paragraph.width,
|
||||
other => panic!("expected paragraph, got {other:?}"),
|
||||
}
|
||||
};
|
||||
assert!(
|
||||
width("mmm") > width("iii"),
|
||||
"Computer Modern m is wider than i"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tall_insertions_split_across_pages() {
|
||||
let document = Document::new(
|
||||
|
||||
Reference in new issue
Block a user