#!/usr/bin/perl -- # -*- Perl -*- # build the character entity tables from the glyphtable map # This script must be run in the 'build' directory use XML::DOM; $verbose = shift @ARGV; $entities = "lib/entities.xml"; my $parser = new XML::DOM::Parser (NoExpand => 0); print STDERR "Loading $entities..."; $doc = $parser->parsefile($entities); $root = $doc->getDocumentElement(); $entlist = $root->getElementsByTagName('entity'); print STDERR "\n"; %hex = (); %desc = (); for (my $count = 0; $count < $entlist->getLength(); $count++) { my $ent = $entlist->item($count); my $ucode = $ent->getAttribute('ucode'); my $name = $ent->getAttribute('name'); my $iso = $ent->getAttribute('iso'); my $desce = $ent->getElementsByTagName('desc')->item(0); my $text = $desce->toString(); $text = $1 if $text =~ /(.*)<\/desc>/; next if $ucode eq ''; warn "Ignoring dup: $name\n", next if $hex{$name}; $hex{$name} = $ucode; $desc{$name} = $text; } $dir = "lib/isoents"; $tbldir = "."; $glyphdir = "../../glyphs/100dpi"; $missglyph = 0; $unkglyph = 0; opendir(DIR, $dir); while ($name = readdir(DIR)) { $file = "$dir/$name"; next if ! -f $file; next if $name !~ /^(.*)\.ent$/; $base = $1; open (TBL, ">$tbldir/$base.gen"); print TBL "\n"; print TBL "\n"; print TBL "\n"; print TBL "\n"; print TBL "\n"; print TBL "\n"; print TBL "\n"; print TBL "\n"; print TBL "\n"; print TBL " Entity Name\n"; print TBL " Unicode Code point\n"; print TBL " Sample Glyph\n"; print TBL " Description\n"; print TBL "\n"; print TBL "\n"; print TBL "\n"; open(F, $file); while () { chop; if (/\n $name$code\n"; print TBL " "; print TBL "\n\n"; print TBL "\n"; print TBL "\n"; print TBL "\n"; print TBL "Unicode $code\n"; print TBL "\n"; print TBL ""; print TBL "\n $desc\n"; print TBL "\n"; } } close (F); print TBL "\n"; print TBL "\n"; print TBL "\n"; } closedir(DIR); print "$missglyph missing glyphs.\n"; print "$unkglyph unknown glyphs.\n";