use crate::jab::jab_lib::packages::AccessibleTextAttributesInfo;
#[derive(Debug)]
pub struct AccessibleTextAttributes {
pub bold: bool,
pub italic: bool,
pub underline: bool,
pub strikethrough: bool,
pub superscript: bool,
pub subscript: bool,
pub background_color: String,
pub foreground_color: String,
pub font_family: String,
pub font_size: i32,
pub alignment: i32,
pub bidi_level: i32,
pub first_line_indent: f32,
pub left_indent: f32,
pub right_indent: f32,
pub line_spacing: f32,
pub space_above: f32,
pub space_below: f32,
pub full_attributes_string: String,
}
impl AccessibleTextAttributes {
pub(crate) fn new(info: AccessibleTextAttributesInfo) -> Self {
Self {
bold: info.bold != 0,
italic: info.italic != 0,
underline: info.underline != 0,
strikethrough: info.strikethrough != 0,
superscript: info.superscript != 0,
subscript: info.subscript != 0,
background_color: String::from_utf16_lossy(&info.backgroundColor)
.trim_matches('\0')
.to_string(),
foreground_color: String::from_utf16_lossy(&info.foregroundColor)
.trim_matches('\0')
.to_string(),
font_family: String::from_utf16_lossy(&info.fontFamily)
.trim_matches('\0')
.to_string(),
font_size: info.fontSize,
alignment: info.alignment,
bidi_level: info.bidiLevel,
first_line_indent: info.firstLineIndent,
left_indent: info.leftIndent,
right_indent: info.rightIndent,
line_spacing: info.lineSpacing,
space_above: info.spaceAbove,
space_below: info.spaceBelow,
full_attributes_string: String::from_utf16_lossy(&info.fullAttributesString)
.trim_matches('\0')
.to_string(),
}
}
}