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 more