Browse Source

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

master
Alex 'AdUser' Z 8 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' },
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
}

Loading…
Cancel
Save