summaryrefslogtreecommitdiff
path: root/src/doc.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2019-10-11 20:28:22 +0200
committerLaurenz <laurmaedje@gmail.com>2019-10-11 20:28:22 +0200
commit6f22e4f13c42f06b686a01fbdd28a0163e88ae77 (patch)
treea78145f5f9d84325529a8529875c9ef6ca5b9a1a /src/doc.rs
parentc0e4fd55e6fa738cfc5dcc851d0fc3ee2d0f2cd2 (diff)
Render debug boxes 🧭
Diffstat (limited to 'src/doc.rs')
-rw-r--r--src/doc.rs27
1 files changed, 2 insertions, 25 deletions
diff --git a/src/doc.rs b/src/doc.rs
index d83ae635..9a287913 100644
--- a/src/doc.rs
+++ b/src/doc.rs
@@ -1,7 +1,7 @@
//! Representation of typesetted documents.
-use std::io::{self, Write};
-use crate::size::{Size, Size2D};
+use crate::layout::LayoutAction;
+use crate::size::Size;
/// A complete typesetted document, which can be exported.
@@ -21,26 +21,3 @@ pub struct Page {
/// Layouting actions specifying how to draw content on the page.
pub actions: Vec<LayoutAction>,
}
-
-/// A layouting action.
-#[derive(Debug, Clone)]
-pub enum LayoutAction {
- /// Move to an absolute position.
- MoveAbsolute(Size2D),
- /// Set the font by index and font size.
- SetFont(usize, f32),
- /// Write text starting at the current position.
- WriteText(String),
-}
-
-impl LayoutAction {
- /// Serialize this layout action into a string representation.
- pub fn serialize<W: Write>(&self, f: &mut W) -> io::Result<()> {
- use LayoutAction::*;
- match self {
- MoveAbsolute(s) => write!(f, "m {:.4} {:.4}", s.x.to_pt(), s.y.to_pt()),
- SetFont(i, s) => write!(f, "f {} {}", i, s),
- WriteText(s) => write!(f, "w {}", s),
- }
- }
-}