ppt_rs/generator/text/
mod.rs1mod format;
10mod run;
11mod paragraph;
12mod frame;
13pub mod rtl;
14
15pub use format::{TextFormat, FormattedText, color_to_xml};
16pub use run::Run;
17pub use paragraph::Paragraph;
18pub use frame::TextFrame;
19pub use rtl::{TextDirection, RtlLanguage, RtlTextProps};
20
21#[derive(Clone, Debug, Copy, PartialEq, Eq, Default)]
23pub enum TextAlign {
24 #[default]
25 Left,
26 Center,
27 Right,
28 Justify,
29}
30
31impl TextAlign {
32 pub fn to_xml(&self) -> &'static str {
34 match self {
35 TextAlign::Left => "l",
36 TextAlign::Center => "ctr",
37 TextAlign::Right => "r",
38 TextAlign::Justify => "just",
39 }
40 }
41}
42
43#[derive(Clone, Debug, Copy, PartialEq, Eq, Default)]
45pub enum TextAnchor {
46 #[default]
47 Top,
48 Middle,
49 Bottom,
50}
51
52impl TextAnchor {
53 pub fn to_xml(&self) -> &'static str {
55 match self {
56 TextAnchor::Top => "t",
57 TextAnchor::Middle => "ctr",
58 TextAnchor::Bottom => "b",
59 }
60 }
61}
62
63pub(crate) use crate::core::escape_xml;
64
65
66#[cfg(test)]
67mod tests {
68 use super::*;
69
70 #[test]
71 fn test_text_align() {
72 assert_eq!(TextAlign::Left.to_xml(), "l");
73 assert_eq!(TextAlign::Center.to_xml(), "ctr");
74 assert_eq!(TextAlign::Right.to_xml(), "r");
75 assert_eq!(TextAlign::Justify.to_xml(), "just");
76 }
77
78 #[test]
79 fn test_text_anchor() {
80 assert_eq!(TextAnchor::Top.to_xml(), "t");
81 assert_eq!(TextAnchor::Middle.to_xml(), "ctr");
82 assert_eq!(TextAnchor::Bottom.to_xml(), "b");
83 }
84}