File strip-source.pl of Package ctan-latinmodern-fonts

#!/usr/bin/perl
#
# The origin source archive ships fonts redundantly.
# Since TrueType is vector based, there is not much point
# in having both lmroman5-bold.otf and lmroman6-bold.otf.
#
# Run this in a directory to which the .otfs have been extracted to.
#

use strict;
my %seen;

# Grab biggest variants
my @files = glob("*.otf");
foreach my $file (@files) {
	my($size) = ($file =~ m{(\d+)});
	my $name = "$`$'";
	if ($seen{$name} < $size) {
		$seen{$name} = $size;
	}
}

foreach my $file (@files) {
	my($size) = ($file =~ m{(\d+)});
	my $name = "$`$'";

	if ($size != $seen{$name}) {
		print "Unlinking $file (retaining $`$seen{$name}$')\n";
		unlink $file;
	}
}
openSUSE Build Service is sponsored by