From 6f22e4f13c42f06b686a01fbdd28a0163e88ae77 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 11 Oct 2019 20:28:22 +0200 Subject: =?UTF-8?q?Render=20debug=20boxes=20=F0=9F=A7=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/doc.rs | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'src/doc.rs') 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, } - -/// 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(&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), - } - } -} -- cgit v1.2.3