* added U+233D-U+233E, U+234B, U+2352, U+236B-U+236D, U+2388
[dejavu.git] / dejavu-fonts / unhinted.pl
blob033804f1879f1c8228a0eba4c4efaf5430efd6fd
1 #!/usr/bin/perl -w
3 # $Id$
5 # output (TT-)unhinted glyphs
6 # (c)2005 Stepan Roh (PUBLIC DOMAIN)
7 # usage: ./unhinted.pl [-v] [-c] sfd_files+
9 sub parse_sfd_file($$$);
11 sub parse_sfd_file($$$) {
12 my ($sfd_file, $verbose, $composites) = @_;
14 open (SFD, $sfd_file) || die "Unable to open $sfd_file : $!\n";
15 print $sfd_file, ': ';
16 my $typeface = '';
17 my $curchar = '';
18 my $hex_enc = '';
19 my $empty = 0;
20 my $hinted = 0;
21 my $total = 0;
22 my $unhinted = 0;
23 my $experimental = 0;
24 my @unhinted = ();
25 my $contours = 0;
26 while (<SFD>) {
27 if (/^FullName:\s+\S+\s+(.*?)\s*$/) {
28 $typeface = $1;
29 $experimental = ($typeface =~ /Condensed|(Serif.*Oblique)/);
30 } elsif (/^StartChar:\s*(\S+)\s*$/) {
31 $curchar = $1;
32 $hex_enc = '';
33 $empty = 0;
34 $hinted = 0;
35 $contours = 0;
36 } elsif (/^TtfInstrs:/) {
37 $hinted = 1;
38 } elsif (/^Colour:/) {
39 # XXX this is quick'n'dirty hack to detect non-empty glyphs
40 $empty = 1;
41 } elsif (/^Fore$/) {
42 $contours = 1;
43 } elsif (/^Encoding:\s*\d+\s*(\d+)\s*\d+\s*$/) {
44 $hex_enc = sprintf ('%04X', $1);
45 } elsif ($hex_enc && !$empty && /^EndChar\s*$/) {
46 $total++;
47 if (($composites || $contours) && !$hinted) {
48 $unhinted++;
49 push (@unhinted, $curchar . ' (U+' . $hex_enc . ')');
53 print "[experimental] " if ($experimental);
54 printf "%.0d%% (%d/%d)", $unhinted / $total * 100, $unhinted, $total;
55 print "\n";
56 print ' ', join (', ', @unhinted), "\n" if ($verbose);
57 close (SFD);
60 if (@ARGV < 1) {
61 print STDERR "usage: [-v] [-c] sfd_files+\n";
62 exit 1;
65 while ($ARGV[0] =~ /^-/) {
66 if ($ARGV[0] eq '-v') {
67 $verbose = 1;
68 } elsif ($ARGV[0] eq '-c') {
69 $composites = 1;
70 } else {
71 last;
73 shift @ARGV;
75 @sfd_files = @ARGV;
77 foreach $sfd_file (@sfd_files) {
78 parse_sfd_file ($sfd_file, $verbose, $composites);