Debian Codegraph @

tools/test/MES-Conformance/CheckConformance.pl

raw
1 #!/usr/bin/perl
2 # $Id: CheckConformance.pl,v 1.1 2009-12-27 16:25:15 Stevan_White Exp $
3 #
4 # Check conformance of font file with given character sets.
5
6 # Get the characters in the font file
7 # Regexp for ENCODING line matches BDF and PfaEdit's SFD formats
8 if ($#ARGV >= 0) {
9 open(FONTFILE, $ARGV[0]);
10 } else {
11 open(FONTFILE, "<stdin");
12 }
13 while (<FONTFILE>) {
14 if (/^E[Nn][Cc][Oo][Dd][Ii][Nn][Gg]:? ([\d]+)/) {
15 $char{$1} = 1;
16 }
17 }
18 close (FONTFILE);
19
20 $tbldir = "./";
21 @tables = ("MES-1.lst", "MES-2.lst", "MES-3B.lst");
22
23 foreach $table (0 .. $#tables) {
24
25 $tblfile = $tbldir.$tables[$table];
26
27 # Read in the table with the named entities
28 open(TABLE, "<$tblfile") || die "Cannot find $tblfile\n";
29 delete @table{keys %table};
30 while (<TABLE>) {
31 if (/^\#.*/) {
32 next;
33 } else {
34 chomp;
35 ($code,$name) = split(/:/, $_, 9999);
36 $table{hex($code)} = $name;
37 }
38 }
39 close(TABLE);
40
41 # Get the list of missing chars, sorted numerically by their code
42 foreach $key (sort {$a <=> $b} keys %table) {
43 if ($char{$key} != 1) {
44 push @missing, $key;
45 }
46 }
47
48 # Print the list of missing chars, code and ISO 10646 name
49 if ($#missing >= 0) {
50 print "\n$#missing characters are found missing for conformance with ";
51 print "$tblfile:\n";
52 for ($i = 0; $i <= $#missing; $i++) {
53 printf("%04X %s\n", $missing[$i], $table{$missing[$i]});
54 }
55 } else {
56 print "\nCongratulations!\n";
57 print "No characters are found missing for conformance with ";
58 print "$tblfile.\n";
59 }
60 }