Browse Source

* Subtitle::SSA::Style : enable 'float' values format

master
Alex 'AdUser' Z 9 years ago
parent
commit
09b6e487f9
  1. 12
      lib/Subtitle/SSA/Style.pm

12
lib/Subtitle/SSA/Style.pm

@ -28,11 +28,11 @@ my %STYLE_DEFAULTS = (
strikeout => { type => 'b', value => 0, name => 'StrikeOut' }, strikeout => { type => 'b', value => 0, name => 'StrikeOut' },
scalex => { type => 'd', value => 100, name => 'ScaleX' }, scalex => { type => 'd', value => 100, name => 'ScaleX' },
scaley => { type => 'd', value => 100, name => 'ScaleY' }, scaley => { type => 'd', value => 100, name => 'ScaleY' },
spacing => { type => 'd', value => 0, name => 'Spacing' }, spacing => { type => 'f', value => 0, name => 'Spacing' },
angle => { type => 'd', value => 0, name => 'Angle' }, angle => { type => 'f', value => 0, name => 'Angle' },
borderstyle => { type => 'd', value => 1, name => 'BorderStyle' }, borderstyle => { type => 'd', value => 1, name => 'BorderStyle' },
outline => { type => 'd', value => 2, name => 'Outline' }, outline => { type => 'f', value => 2, name => 'Outline' },
shadow => { type => 'd', value => 0, name => 'Shadow' }, shadow => { type => 'f', value => 0, name => 'Shadow' },
alignment => { type => 'd', value => 2, name => 'Alignment' }, alignment => { type => 'd', value => 2, name => 'Alignment' },
marginl => { type => 'd', value => 10, name => 'MarginL' }, marginl => { type => 'd', value => 10, name => 'MarginL' },
marginr => { type => 'd', value => 10, name => 'MarginR' }, marginr => { type => 'd', value => 10, name => 'MarginR' },
@ -88,6 +88,10 @@ sub to_string {
if ($d->{type} eq 'x') { if ($d->{type} eq 'x') {
$fmt = ($self->{_vers} eq 'ass') ? '&H%08X' : '%d'; $fmt = ($self->{_vers} eq 'ass') ? '&H%08X' : '%d';
$v = sprintf $fmt, $v; $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 { } else {
# use as is # use as is
} }

Loading…
Cancel
Save