pub struct StylingInfo {
pub font_name: Option<String>,
pub font_size: Option<u32>,
pub color: Option<String>,
pub bold: bool,
pub italic: bool,
pub underline: bool,
}Expand description
Optional styling information for subtitle entries with comprehensive formatting support.
This structure contains visual formatting information that can be applied to subtitle text. Not all formats support all styling options, and some styling may be lost during format conversions.
§Format Support
- SRT: Limited support (bold, italic, underline via HTML tags)
- ASS: Full support for all styling options plus advanced features
- VTT: Good support via CSS-style declarations
- SUB: No styling support (ignored)
§Color Format
Colors can be specified in various formats:
- Hex: “#FF0000”, “#ff0000”
- RGB: “rgb(255, 0, 0)”
- Named: “red”, “blue”, “white”
- ASS format: “&H0000FF&” (BGR order)
§Examples
use subx_cli::core::formats::StylingInfo;
// Basic text styling
let basic_style = StylingInfo {
bold: true,
italic: false,
underline: false,
..Default::default()
};
// Complete styling with font and color
let full_style = StylingInfo {
font_name: Some("Arial".to_string()),
font_size: Some(20),
color: Some("#FFFFFF".to_string()),
bold: true,
italic: false,
underline: false,
};
assert!(full_style.has_font_styling());
assert!(full_style.has_text_decoration());Fields§
§font_name: Option<String>Font family name for the subtitle text.
Common fonts: “Arial”, “Times New Roman”, “Helvetica”, “SimHei” Some formats may fall back to default fonts if not available.
font_size: Option<u32>Font size in points or pixels (format-dependent).
Typical ranges: 12-24 for normal subtitles, larger for accessibility. The exact interpretation depends on the target format.
color: Option<String>Text color specification.
Supports multiple formats: hex (#FF0000), RGB, named colors. Default is usually white (#FFFFFF) for video subtitles.
bold: boolWhether the text should be rendered in bold weight.
italic: boolWhether the text should be rendered in italic style.
underline: boolWhether the text should have underline decoration.
Implementations§
Source§impl StylingInfo
impl StylingInfo
Sourcepub fn has_font_styling(&self) -> bool
pub fn has_font_styling(&self) -> bool
Check if any font-related styling is applied.
Returns true if font name, size, or color is specified.
Sourcepub fn has_text_decoration(&self) -> bool
pub fn has_text_decoration(&self) -> bool
Check if any text decoration is applied.
Returns true if bold, italic, or underline is enabled.
Sourcepub fn has_any_styling(&self) -> bool
pub fn has_any_styling(&self) -> bool
Check if any styling is applied at all.
Returns true if either font styling or text decoration is present.
Sourcepub fn normalized_color(&self) -> Option<String>
pub fn normalized_color(&self) -> Option<String>
Convert color to hex format if possible.
Attempts to normalize the color specification to #RRGGBB format. Returns the original color string if conversion is not possible.
Trait Implementations§
Source§impl Clone for StylingInfo
impl Clone for StylingInfo
Source§fn clone(&self) -> StylingInfo
fn clone(&self) -> StylingInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StylingInfo
impl Debug for StylingInfo
Source§impl Default for StylingInfo
impl Default for StylingInfo
Source§fn default() -> StylingInfo
fn default() -> StylingInfo
Auto Trait Implementations§
impl Freeze for StylingInfo
impl RefUnwindSafe for StylingInfo
impl Send for StylingInfo
impl Sync for StylingInfo
impl Unpin for StylingInfo
impl UnwindSafe for StylingInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.