#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TextAlignment {
Left,
Center,
Right,
Justify,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Margins {
pub top: f32,
pub right: f32,
pub bottom: f32,
pub left: f32,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct BasicTextStyle {
pub size: u8,
pub text_color: Option<(u8, u8, u8)>,
pub before_spacing: f32,
pub after_spacing: f32,
pub alignment: Option<TextAlignment>,
pub font_family: Option<&'static str>,
pub bold: bool,
pub italic: bool,
pub underline: bool,
pub strikethrough: bool,
pub background_color: Option<(u8, u8, u8)>,
}
impl BasicTextStyle {
pub fn new(
size: u8,
text_color: Option<(u8, u8, u8)>,
before_spacing: Option<f32>,
after_spacing: Option<f32>,
alignment: Option<TextAlignment>,
font_family: Option<&'static str>,
bold: bool,
italic: bool,
underline: bool,
strikethrough: bool,
background_color: Option<(u8, u8, u8)>,
) -> Self {
Self {
size,
text_color,
before_spacing: before_spacing.unwrap_or(0.0),
after_spacing: after_spacing.unwrap_or(0.0),
alignment,
font_family,
bold,
italic,
underline,
strikethrough,
background_color,
}
}
}
impl Default for BasicTextStyle {
fn default() -> Self {
Self::new(
12, None, None, None, None, None, false, false, false, false, None,
)
}
}
pub struct StyleMatch {
pub margins: Margins,
pub heading_1: BasicTextStyle,
pub heading_2: BasicTextStyle,
pub heading_3: BasicTextStyle,
pub emphasis: BasicTextStyle,
pub strong_emphasis: BasicTextStyle,
pub code: BasicTextStyle,
pub block_quote: BasicTextStyle,
pub list_item: BasicTextStyle,
pub link: BasicTextStyle,
pub image: BasicTextStyle,
pub text: BasicTextStyle,
pub table_header: BasicTextStyle,
pub table_cell: BasicTextStyle,
pub horizontal_rule: BasicTextStyle,
}
impl Default for StyleMatch {
fn default() -> Self {
Self {
margins: Margins {
top: 8.0,
right: 8.0,
bottom: 8.0,
left: 8.0,
},
heading_1: BasicTextStyle::new(
14,
Some((0, 0, 0)),
Some(0.8),
Some(0.5),
Some(TextAlignment::Center),
None,
true,
false,
false,
false,
None,
),
heading_2: BasicTextStyle::new(
12,
Some((0, 0, 0)),
Some(0.8),
Some(0.5),
Some(TextAlignment::Left),
None,
true,
false,
false,
false,
None,
),
heading_3: BasicTextStyle::new(
10,
Some((0, 0, 0)),
Some(0.8),
Some(0.5),
Some(TextAlignment::Left),
None,
true,
false,
false,
false,
None,
),
emphasis: BasicTextStyle::new(
8,
Some((0, 0, 0)),
None,
None,
None,
None,
false,
true,
false,
false,
None,
),
strong_emphasis: BasicTextStyle::new(
8,
Some((0, 0, 0)),
None,
None,
None,
None,
true,
false,
false,
false,
None,
),
code: BasicTextStyle::new(
8,
Some((128, 128, 128)),
Some(0.4),
Some(0.4),
None,
Some("Roboto"),
false,
false,
false,
false,
Some((230, 230, 230)),
),
block_quote: BasicTextStyle::new(
8,
Some((128, 128, 128)),
None,
None,
None,
None,
false,
true,
false,
false,
Some((245, 245, 245)),
),
list_item: BasicTextStyle::new(
8,
Some((0, 0, 0)),
None,
Some(0.5),
None,
None,
false,
false,
false,
false,
None,
),
table_header: BasicTextStyle::new(
8,
Some((0, 0, 0)),
None,
None,
None,
None,
false,
false,
false,
false,
None,
),
table_cell: BasicTextStyle::new(
8,
Some((0, 0, 0)),
None,
None,
None,
None,
false,
false,
false,
false,
None,
),
link: BasicTextStyle::new(
8,
Some((128, 128, 128)),
None,
None,
None,
None,
false,
false,
true,
false,
None,
),
image: BasicTextStyle::new(
8,
Some((0, 0, 0)),
None,
None,
Some(TextAlignment::Center),
None,
false,
false,
false,
false,
None,
),
text: BasicTextStyle::new(
8,
Some((0, 0, 0)),
None,
None,
None,
None,
false,
false,
false,
false,
None,
),
horizontal_rule: BasicTextStyle::new(
8,
Some((0, 0, 0)),
None,
Some(0.5),
None,
None,
false,
false,
false,
false,
None,
),
}
}
}