Split paragraphs at line boundaries across pages
This commit is contained in:
1 parent
daf9f5c57e
commit
b7b75fbff1
8 files changed
+263
-77
No files matched your search
@@ -2,7 +2,7 @@
|
||||
//! incremental paragraph edit.
|
||||
|
||||
use texrra_tex_core::{
|
||||
Document, Engine, ParagraphFont, ParagraphStyle, Unit,
|
||||
Document, Engine, ParagraphFont, ParagraphStyle, Unit, VerticalItem,
|
||||
cmr10::Cmr10Metrics,
|
||||
pdf::{PageOrigin, display_lists_to_pdf, display_lists_to_pdf_with_origin},
|
||||
};
|
||||
@@ -47,19 +47,29 @@ fn body_style() -> ParagraphStyle {
|
||||
|
||||
fn paragraph(id: u64, marker: &str) -> Unit {
|
||||
let text = format!("{} {}", marker, "alpha beta gamma delta ".repeat(80));
|
||||
Unit::paragraph_with_style(id, text, ParagraphStyle::default())
|
||||
Unit::paragraph_with_style(id, text, body_style())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn route_d_article_exports_pdf_and_reflows_only_the_edited_page() {
|
||||
let document = Document::new(
|
||||
20,
|
||||
let mut document = Document::new(
|
||||
1,
|
||||
vec![
|
||||
paragraph(1, "ONE"),
|
||||
paragraph(2, "TWO"),
|
||||
paragraph(3, "THREE"),
|
||||
],
|
||||
);
|
||||
// One full paragraph is exactly one page, so the test is about the
|
||||
// incremental checkpoint boundary rather than page overflow.
|
||||
document.page_goal = document
|
||||
.units
|
||||
.iter()
|
||||
.find_map(|unit| match &unit.items[0] {
|
||||
VerticalItem::Paragraph(paragraph) => Some(paragraph.height),
|
||||
_ => None,
|
||||
})
|
||||
.expect("paragraph units");
|
||||
let mut engine = Engine::layout(&document);
|
||||
assert!(engine.pages().len() >= 3, "expected one page per paragraph");
|
||||
|
||||
|
||||
Reference in new issue
Block a user