1#!/usr/bin/env perl 2# $Id: pickchars,v 1.4 2003/08/05 16:26:37 s42335 Exp $ 3# 4# usage: pickchars idfile bdf1 bdf2 ... 5# 6# pick up the glyphs specified in idfile and dump it sorted. 7# 8# 2002/2/3, by 1@2ch 9# * public domain * 10# 11 12$p=$0; $p=~s:[^/]+$::; push(@INC,$p); 13require 'lib_util.pl'; 14 15sub usage() { 16 print "usage: pickchars idfile bdf1 bdf2 ...\n"; 17 exit 1; 18} 19 20$ARGV[0] || usage(); 21 22 23%glyph = (); 24sub font1 { 25 open(IN, $_[0]) || die("open: $_[0]: $!"); 26 my $b = 0, $e = 0; 27 while(<IN>) { 28 my @F = split(/\s+/); 29 my $c = shift(@F); 30 if ($c eq 'STARTCHAR') { 31 $b = 1; 32 $e = 0; 33 $s = ''; 34 } 35 $s .= $_ if ($b); 36 if ($c eq 'ENCODING') { 37 $e = $F[0]; 38 } 39 if ($c eq 'ENDCHAR') { 40 $b = 0; 41 if ($e && $enc{$e}) { 42 $glyph{$e} = $s; 43 } 44 } 45 } 46 close(IN); 47} 48 49$f=shift(@ARGV); 50open(IN, $f) || die("open: $f: $!"); 51while($_ = getline(IN)) { 52 split(/\s+/); 53 $enc{eval($_[0])} = 1; 54} 55close(IN); 56 57foreach my $i (@ARGV) { 58 &font1($i); 59} 60$gid = 1; 61foreach my $i (sort {$a<=>$b} keys(%glyph)) { 62 print "COMMENT GLYPH $gid\n"; 63 print $glyph{$i}; 64 $gid++; 65} 66