From 09b6e487f92a84e69246f333ca33e38fa49a3212 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Thu, 30 Jun 2016 13:40:06 +1000 Subject: [PATCH] * Subtitle::SSA::Style : enable 'float' values format --- lib/Subtitle/SSA/Style.pm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/Subtitle/SSA/Style.pm b/lib/Subtitle/SSA/Style.pm index 70208a8..ef2cd70 100644 --- a/lib/Subtitle/SSA/Style.pm +++ b/lib/Subtitle/SSA/Style.pm @@ -28,11 +28,11 @@ my %STYLE_DEFAULTS = ( strikeout => { type => 'b', value => 0, name => 'StrikeOut' }, scalex => { type => 'd', value => 100, name => 'ScaleX' }, scaley => { type => 'd', value => 100, name => 'ScaleY' }, - spacing => { type => 'd', value => 0, name => 'Spacing' }, - angle => { type => 'd', value => 0, name => 'Angle' }, + spacing => { type => 'f', value => 0, name => 'Spacing' }, + angle => { type => 'f', value => 0, name => 'Angle' }, borderstyle => { type => 'd', value => 1, name => 'BorderStyle' }, - outline => { type => 'd', value => 2, name => 'Outline' }, - shadow => { type => 'd', value => 0, name => 'Shadow' }, + outline => { type => 'f', value => 2, name => 'Outline' }, + shadow => { type => 'f', value => 0, name => 'Shadow' }, alignment => { type => 'd', value => 2, name => 'Alignment' }, marginl => { type => 'd', value => 10, name => 'MarginL' }, marginr => { type => 'd', value => 10, name => 'MarginR' }, @@ -88,6 +88,10 @@ sub to_string { if ($d->{type} eq 'x') { $fmt = ($self->{_vers} eq 'ass') ? '&H%08X' : '%d'; $v = sprintf $fmt, $v; + } elsif ($d->{type} eq 'f') { + $v = sprintf "%.2f", $v; + # hack: make decimal from float if fractional part is zero after round up + $v =~ s{\.00$}{}oi; } else { # use as is }