X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/ef7911fba9c330552599bc6eb9dc22606246dd7e..68b03397a0872d10d3627cea2b92ae36bd59183c:/font-optimizer/list-features.pl diff --git a/font-optimizer/list-features.pl b/font-optimizer/list-features.pl new file mode 100755 index 0000000..3264a48 --- /dev/null +++ b/font-optimizer/list-features.pl @@ -0,0 +1,52 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use lib 'ext/Font-TTF/lib'; +use Font::TTF::Font; + +use Getopt::Long; + +main(); + +sub help { + print <open($input_file) or die "Error opening $input_file: $!"; + + my %feats; + my @feats; + for my $table (grep defined, $font->{GPOS}, $font->{GSUB}) { + $table->read; + for my $feature (@{$table->{FEATURES}{FEAT_TAGS}}) { + $feature =~ /^(\w{4})( _\d+)?$/ or die "Unrecognised feature tag syntax '$feature'"; + my $tag = $1; + next if $feats{$tag}++; + push @feats, $tag; + } + } + print map "$_\n", @feats; + + $font->release; +}