diff options
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), } |
