Skip to main content

paperforge_layout/
paragraph.rs

1use paperforge_core::Color;
2
3use crate::element::{Align, Paragraph};
4
5pub struct ParagraphBuilder {
6    paragraph: Paragraph,
7}
8
9impl ParagraphBuilder {
10    pub fn new(text: &str) -> Self {
11        Self {
12            paragraph: Paragraph::new(text),
13        }
14    }
15
16    pub fn align(mut self, align: Align) -> Self {
17        self.paragraph.align = align;
18        self
19    }
20
21    pub fn font_size(mut self, size: f64) -> Self {
22        self.paragraph.font_size = size;
23        self
24    }
25
26    pub fn color(mut self, color: Color) -> Self {
27        self.paragraph.color = color;
28        self
29    }
30
31    pub fn line_spacing(mut self, spacing: f64) -> Self {
32        self.paragraph.line_spacing = spacing;
33        self
34    }
35
36    pub fn build(self) -> Paragraph {
37        self.paragraph
38    }
39}