Add a minimal PDF writer for route-D display lists
This commit is contained in:
1 parent
946f8b1b76
commit
b6fab85f61
3 files changed
+113
No files matched your search
@@ -1,6 +1,7 @@
|
||||
pub mod cmr10;
|
||||
pub mod math;
|
||||
pub mod paragraph;
|
||||
pub mod pdf;
|
||||
pub mod render;
|
||||
|
||||
pub use cmr10::Cmr10Metrics;
|
||||
@@ -1321,6 +1322,19 @@ mod tests {
|
||||
assert_eq!(halign.cell_box(2, 0), Some((30, 110)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn display_list_writes_a_minimal_pdf() {
|
||||
let document = Document::new(400, vec![Unit::paragraph(1, "hello")]);
|
||||
let engine = Engine::layout(&document);
|
||||
let list = engine.pages()[0].display_list();
|
||||
let pdf = crate::pdf::display_list_to_pdf(&list, 400 * 65_536);
|
||||
let text = String::from_utf8_lossy(&pdf);
|
||||
assert!(text.starts_with("%PDF-1.4"));
|
||||
assert!(text.contains("/Type /Page "));
|
||||
assert!(text.contains("/BaseFont /Times-Roman"));
|
||||
assert!(text.contains("Tj"));
|
||||
assert!(text.trim_end().ends_with("%%EOF"));
|
||||
}
|
||||
#[test]
|
||||
fn math_display_list_paints_symbols_and_fraction_rule() {
|
||||
let atom = crate::math::parse_math("x + \\frac{a}{b}");
|
||||
|
||||
Reference in new issue
Block a user