You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
3.0 KiB
71 lines
3.0 KiB
6 years ago
|
package Subtitle::Format::SSA::Style;
|
||
9 years ago
|
|
||
|
use strict;
|
||
|
use warnings;
|
||
|
use utf8;
|
||
|
|
||
6 years ago
|
use base 'Subtitle::Format::SSA::Record';
|
||
9 years ago
|
|
||
9 years ago
|
my @FIELDS_SSA = qw(name fontname fontsize primarycolour secondarycolour tertiarycolour backcolour bold italic borderstyle outline shadow alignment marginl marginr marginv alphalevel encoding);
|
||
9 years ago
|
my @FIELDS_ASS = qw(name fontname fontsize primarycolour secondarycolour outlinecolour backcolour bold italic underline strikeout scalex scaley spacing angle borderstyle outline shadow alignment marginl marginr marginv encoding);
|
||
|
|
||
9 years ago
|
# see parse() description for available type's
|
||
9 years ago
|
my %FIELDS = (
|
||
9 years ago
|
name => { type => 's', value => 'Default', name => 'Name' },
|
||
|
fontname => { type => 's', value => 'Arial' , name => 'Fontname' },
|
||
|
primarycolour => { type => 'x', value => 0x00FFFFFF, name => 'PrimaryColour' },
|
||
|
secondarycolour => { type => 'x', value => 0x00000000, name => 'SecondaryColour' },
|
||
|
outlinecolour => { type => 'x', value => 0x004E3873, name => 'OutlineColour' },
|
||
9 years ago
|
tertiarycolour => { type => 'x', value => 0x004E3873, name => 'TertiaryColour' },
|
||
9 years ago
|
backcolour => { type => 'x', value => 0x96000000, name => 'BackColour' },
|
||
|
fontsize => { type => 'd', value => 24, name => 'Fontsize' },
|
||
|
bold => { type => 'b', value => 0, name => 'Bold' },
|
||
|
italic => { type => 'b', value => 0, name => 'Italic' },
|
||
|
underline => { type => 'b', value => 0, name => 'Underline' },
|
||
|
strikeout => { type => 'b', value => 0, name => 'StrikeOut' },
|
||
|
scalex => { type => 'd', value => 100, name => 'ScaleX' },
|
||
|
scaley => { type => 'd', value => 100, name => 'ScaleY' },
|
||
9 years ago
|
spacing => { type => 'f', value => 0, name => 'Spacing' },
|
||
|
angle => { type => 'f', value => 0, name => 'Angle' },
|
||
9 years ago
|
borderstyle => { type => 'd', value => 1, name => 'BorderStyle' },
|
||
9 years ago
|
outline => { type => 'f', value => 2, name => 'Outline' },
|
||
|
shadow => { type => 'f', value => 0, name => 'Shadow' },
|
||
9 years ago
|
alignment => { type => 'd', value => 2, name => 'Alignment' },
|
||
|
marginl => { type => 'd', value => 10, name => 'MarginL' },
|
||
|
marginr => { type => 'd', value => 10, name => 'MarginR' },
|
||
|
marginv => { type => 'd', value => 10, name => 'MarginV' },
|
||
9 years ago
|
alphalevel => { type => 'd', value => 0, name => 'AlphaLevel' },
|
||
9 years ago
|
encoding => { type => 'd', value => 204, name => 'Encoding' },
|
||
|
);
|
||
8 years ago
|
|
||
|
# options:
|
||
8 years ago
|
# * type - 'ssa' for v4 or 'ass' for v4+
|
||
8 years ago
|
sub new {
|
||
|
my ($class, %opts) = @_;
|
||
|
my $self = {
|
||
8 years ago
|
_type => 'ass',
|
||
8 years ago
|
_fields => \%FIELDS,
|
||
|
_format => \@FIELDS_ASS,
|
||
|
_prefix => 'Style',
|
||
|
};
|
||
|
|
||
8 years ago
|
if (my $t = $opts{type}) {
|
||
|
if ($t =~ m{^(ass|ssa)$}oi) {
|
||
|
$self->{_type} = lc($t);
|
||
8 years ago
|
} else {
|
||
8 years ago
|
die("unsupported event type $t");
|
||
8 years ago
|
}
|
||
|
}
|
||
|
|
||
|
$self->{_format} = \@FIELDS_SSA
|
||
8 years ago
|
if $self->{_type} eq 'ssa';
|
||
8 years ago
|
|
||
|
my @fields = @{ $self->{_format} };
|
||
|
$self->{$_} = $FIELDS{$_}->{value}
|
||
|
foreach @fields;
|
||
|
|
||
|
return bless($self, $class);
|
||
|
}
|
||
9 years ago
|
|
||
|
1;
|