#!/usr/bin/perl # # findttf.pl # # (c) F. Dispot 2000 # # Finds a ttf font after a name regexp pattern, in the ttname.dir # catalogue. # # Usage : findttf.pl # $font_name = $ARGV[0]; print "Search for: $font_name\n"; # Adapt path below according to your config open (TTN, "/usr/ttfonts/ttname.dir"); read (TTN, $fonts, 1000000); # Should hold about 10000 fonts close (TTN); substr($fonts, 0, 16)=""; @cat = split (/\000/, $fonts); $nbm = 0; for ($i=0; $i<= $#cat; $i+=3) { $nom = @cat[$i]; if ($nom =~/$font_name/ig) { $ttf = @cat[$i+1]; printf (" %32s | %s\n", $nom, $ttf); $nbm++; } } printf ("%d match%s found.\n", $nbm, ($nbm<2 ? "" : "es"));