From f09f7a3d98e45bce78bc71e27fe6959f93a2ddd1 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Mon, 23 Jul 2018 02:59:46 +1000 Subject: [PATCH] + Subtitle::SSA->fonts_usage --- lib/Subtitle/SSA.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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;