diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-10-11 20:28:22 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-10-11 20:28:22 +0200 |
| commit | 6f22e4f13c42f06b686a01fbdd28a0163e88ae77 (patch) | |
| tree | a78145f5f9d84325529a8529875c9ef6ca5b9a1a /src/doc.rs | |
| parent | c0e4fd55e6fa738cfc5dcc851d0fc3ee2d0f2cd2 (diff) | |
Render debug boxes ðŸ§
Diffstat (limited to 'src/doc.rs')
| -rw-r--r-- | src/doc.rs | 27 |
1 files changed, 2 insertions, 25 deletions
@@ -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), - } - } -} |
