#[derive(Clone, Debug, Default)]
pub struct SubtitleCue {
pub start_us: i64,
pub end_us: i64,
pub style_ref: Option<String>,
pub positioning: Option<CuePosition>,
pub segments: Vec<Segment>,
}
#[derive(Clone, Debug, Default)]
pub struct CuePosition {
pub x: Option<f32>,
pub y: Option<f32>,
pub align: TextAlign,
pub size: Option<f32>,
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum TextAlign {
#[default]
Start,
Center,
End,
Left,
Right,
}
#[derive(Clone, Debug)]
pub enum Segment {
Text(String),
LineBreak,
Bold(Vec<Segment>),
Italic(Vec<Segment>),
Underline(Vec<Segment>),
Strike(Vec<Segment>),
Color {
rgb: (u8, u8, u8),
children: Vec<Segment>,
},
Font {
family: Option<String>,
size: Option<f32>,
children: Vec<Segment>,
},
Voice {
name: String,
children: Vec<Segment>,
},
Class {
name: String,
children: Vec<Segment>,
},
Karaoke {
cs: u32,
children: Vec<Segment>,
},
Timestamp {
offset_us: i64,
},
Raw(String),
}
#[derive(Clone, Debug, Default)]
pub struct SubtitleStyle {
pub name: String,
pub font_family: Option<String>,
pub font_size: Option<f32>,
pub primary_color: Option<(u8, u8, u8, u8)>,
pub outline_color: Option<(u8, u8, u8, u8)>,
pub back_color: Option<(u8, u8, u8, u8)>,
pub bold: bool,
pub italic: bool,
pub underline: bool,
pub strike: bool,
pub align: TextAlign,
pub margin_l: Option<i32>,
pub margin_r: Option<i32>,
pub margin_v: Option<i32>,
pub outline: Option<f32>,
pub shadow: Option<f32>,
}
impl SubtitleStyle {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
..Default::default()
}
}
}