diff options
| author | Laurenz <laurmaedje@gmail.com> | 2019-03-11 22:15:34 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2019-03-11 22:15:34 +0100 |
| commit | 107450ee5ca8e7e0bc03cf6ce9f59268aa20e9f6 (patch) | |
| tree | 4d9df95eb410d7dab96cb7182d6c981ff27f9273 /src/doc.rs | |
| parent | 0511979942625e0b1aa77f090621e4f35a2cf242 (diff) | |
Restructure typeset crate ✈
Diffstat (limited to 'src/doc.rs')
| -rw-r--r-- | src/doc.rs | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -4,20 +4,26 @@ use std::ops; use crate::font::Font; +/// A representation of a typesetted document. #[derive(Debug, Clone, PartialEq)] pub struct Document { + /// The pages of the document. pub pages: Vec<Page>, + /// The fonts used in the document. pub fonts: Vec<Font>, } +/// Default styles for a document. #[derive(Debug, Clone, PartialEq)] pub struct Style { - // Paper + /// The width and height of the paper. pub paper_size: [Size; 2], + /// The [left, top, right, bottom] margins of the paper. pub margins: [Size; 4], - // Font handling + /// A fallback list of font families to use. pub font_families: Vec<String>, + /// The default font size. pub font_size: f32, } @@ -37,22 +43,30 @@ impl Default for Style { } } +/// A page with text contents in a document. #[derive(Debug, Clone, PartialEq)] pub struct Page { - pub width: Size, - pub height: Size, + /// The width and height of the page. + pub size: [Size; 2], + /// Text content on the page. pub text: Vec<Text>, } +/// A series of text command, that can be written on to a page. #[derive(Debug, Clone, PartialEq)] pub struct Text { + /// The text commands. pub commands: Vec<TextCommand>, } +/// Different commands for rendering text. #[derive(Debug, Clone, PartialEq)] pub enum TextCommand { + /// Writing of the text. Text(String), + /// Moves from the *start* of the current line by an (x,y) offset. Move(Size, Size), + /// Use the indexed font in the documents font list with a given font size. SetFont(usize, f32), } |
