mod format;
mod run;
mod paragraph;
mod frame;
pub mod rtl;
pub use format::{TextFormat, FormattedText, color_to_xml};
pub use run::Run;
pub use paragraph::Paragraph;
pub use frame::TextFrame;
pub use rtl::{TextDirection, RtlLanguage, RtlTextProps};
#[derive(Clone, Debug, Copy, PartialEq, Eq, Default)]
pub enum TextAlign {
#[default]
Left,
Center,
Right,
Justify,
}
impl TextAlign {
pub fn to_xml(&self) -> &'static str {
match self {
TextAlign::Left => "l",
TextAlign::Center => "ctr",
TextAlign::Right => "r",
TextAlign::Justify => "just",
}
}
}
#[derive(Clone, Debug, Copy, PartialEq, Eq, Default)]
pub enum TextAnchor {
#[default]
Top,
Middle,
Bottom,
}
impl TextAnchor {
pub fn to_xml(&self) -> &'static str {
match self {
TextAnchor::Top => "t",
TextAnchor::Middle => "ctr",
TextAnchor::Bottom => "b",
}
}
}
pub(crate) use crate::core::escape_xml;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_text_align() {
assert_eq!(TextAlign::Left.to_xml(), "l");
assert_eq!(TextAlign::Center.to_xml(), "ctr");
assert_eq!(TextAlign::Right.to_xml(), "r");
assert_eq!(TextAlign::Justify.to_xml(), "just");
}
#[test]
fn test_text_anchor() {
assert_eq!(TextAnchor::Top.to_xml(), "t");
assert_eq!(TextAnchor::Middle.to_xml(), "ctr");
assert_eq!(TextAnchor::Bottom.to_xml(), "b");
}
}