diff --git a/lib/Subtitle/SSA.pm b/lib/Subtitle/SSA.pm index 63a82f4..427b5e4 100644 --- a/lib/Subtitle/SSA.pm +++ b/lib/Subtitle/SSA.pm @@ -217,4 +217,22 @@ sub style_usage { return $stats; } +sub fonts_usage { + my ($self) = @_; + my $stats = {}; + foreach my $s (@{ $self->{styles} }) { + my $fn = $s->{fontname}; + $stats->{$fn} //= 0; + $stats->{$fn}++; + } + foreach my $e (@{ $self->{events} }) { + next unless index($e->{text}, '\fn') > 0; + my ($fn) = ($e->{text} =~ m<\\fn([^\\}]+)>); + next unless $fn; + $stats->{$fn} //= 0; + $stats->{$fn}++; + } + return $stats; +} + 1;