Skip to main content

ferroui_base/media/text_formatting/
text_paragraph_properties.rs

1use std::rc::Rc;
2
3use crate::media::text_formatting::TextRunProperties;
4use crate::media::{FlowDirection, TextAlignment, TextDecorationCollection, TextWrapping};
5
6/// Provides a set of properties that are used during the paragraph layout.
7pub trait TextParagraphProperties: 'static {
8    /// This property specifies whether the primary text advance direction
9    /// shall be left-to-right, right-to-left.
10    fn flow_direction(&self) -> FlowDirection;
11
12    /// Gets the text alignment.
13    fn text_alignment(&self) -> TextAlignment;
14
15    /// Paragraph's line height.
16    fn line_height(&self) -> f64;
17
18    /// Paragraph's line spacing.
19    fn line_spacing(&self) -> f64 {
20        0.0
21    }
22
23    /// Indicates the first line of the paragraph.
24    fn first_line_in_paragraph(&self) -> bool;
25
26    /// If true, the formatted line may always be collapsed. If false, only
27    /// lines that overflow the paragraph width are collapsed.
28    fn always_collapsible(&self) -> bool {
29        false
30    }
31
32    /// Gets the default text style.
33    fn default_text_run_properties(&self) -> &Rc<dyn TextRunProperties>;
34
35    /// If not null, text decorations to apply to all runs in the line. This
36    /// is in addition to any text decorations specified by the text run
37    /// properties for individual text runs.
38    fn text_decorations(&self) -> Option<&TextDecorationCollection> {
39        None
40    }
41
42    /// Gets the text wrapping.
43    fn text_wrapping(&self) -> TextWrapping;
44
45    /// Line indentation.
46    fn indent(&self) -> f64;
47
48    /// Get the paragraph indentation.
49    fn paragraph_indent(&self) -> f64 {
50        0.0
51    }
52
53    /// Gets the default incremental tab width.
54    fn default_incremental_tab(&self) -> f64 {
55        0.0
56    }
57
58    /// Gets the letter spacing.
59    fn letter_spacing(&self) -> f64 {
60        0.0
61    }
62}