use crate::visual::Color;
use super::style::*;
pub const DEFAULT_CSS: &str = include_str!("presets/default.css");
pub fn list_marker_style() -> Style {
Style {
font_family: vec![
"Source Han Serif SC".to_string(),
"Noto Sans SC".to_string(),
"serif".to_string(),
],
font_size_pt: 10.5,
font_weight: FontWeight::Normal,
font_style: FontStyle::Normal,
color: Color::new(0, 0, 0),
line_height_pt: 15.75,
letter_spacing: 0.0,
text_align: TextAlign::Right,
display: Display::Inline,
margin: BoxSides::ZERO,
padding: BoxSides::ZERO,
border: BoxBorders::NONE,
width: None,
height: None,
object_fit: ObjectFit::None,
background_color: None,
page_break_before: PageBreak::Auto,
page_break_after: PageBreak::Auto,
table_border_color: Color::new(180, 180, 180),
table_border_width_pt: 0.5,
table_cell_padding_h_pt: 4.0,
table_cell_padding_v_pt: 2.0,
table_header_bg: None,
table_alt_row_bg: None,
link_url: None,
text_decoration: TextDecoration::None,
list_indent_pt: None,
text_indent_em: 0.0,
baseline_shift: 0.0,
white_space: WhiteSpace::Normal,
list_style_type: ListStyleType::Disc,
}
}
pub fn computed_style_to_text_style(style: &Style) -> crate::text::TextStyle {
use crate::text::TextAlign as TextAlign2;
let align = match style.text_align {
TextAlign::Left => TextAlign2::Left,
TextAlign::Center => TextAlign2::Center,
TextAlign::Right => TextAlign2::Right,
TextAlign::Justify => TextAlign2::Left, };
crate::text::TextStyle {
color: style.color,
font_family: style.font_family.clone(),
font_size: style.font_size_pt as f64,
font_weight: style.font_weight.as_str().to_string(),
font_style: style.font_style.as_str().to_string(),
align,
url: style.link_url.clone(),
decoration: style.text_decoration,
baseline_shift: style.baseline_shift,
}
}
pub const LIST_INDENT_PT: f32 = 21.0;
pub fn calculate_list_indent(font_size_pt: f32) -> f32 {
font_size_pt * 2.0
}