1#!/usr/bin/env perl 2# $Id: bit2bdf,v 1.2 2002/09/14 20:34:39 euske Exp $ 3# This is a help script to converting font_src.bit to bdf. 4# 5# programmed by KANOU Hiroki <kanou@mil.allnet.ne.jp> 6# modified by Yasuyuki Furukawa <Furukawa.Yasuyuki@fujixerox.co.jp> 7# 8# * public domain * 9# 10 11$verbose = 0; 12$verbose_min = 100; 13 14@vmeter = ("|", "\\", "-", "/"); 15 16for $opt (@ARGV) { 17 if ($opt =~ /^-/) { # option 18 $verbose = 1 if $opt eq '-V'; # verbose 19 next; 20 } else { 21 $file = $opt; 22 last; 23 } 24} 25 26if ($verbose) { 27 $col = int(`stty size 2>/dev/null | sed 's/.* //'`) || 80; 28} 29 30$file= "-" unless $file; 31$ch_count = 0; 32open F, $file || die; 33 34while (<F>) { 35 if (/^ENDCHAR/) { 36 $flag = 0; 37 s/\s*#.*//; 38 print; 39 if (($ch_count++ % 100) == 0 && $verbose != 0 && $max_chars > $verbose_min) { 40 $n = int($ch_count * 100 / $max_chars); 41 $m = int($n * ($col - 21) / 100); 42 $l = $col - 20 - $m; 43 print STDERR "\rprogress|". ("=" x $m). (" " x $l). "$n\%". 44 $vmeter[$ch_count2++ % 4]; 45 } 46 } elsif ($flag == 1) { 47 chomp; 48 tr/pPOo@:;,\\\/./##### /; 49 print unpack("H*", pack("B*", $_)), "\n"; 50 } elsif (/^BITMAP/) { 51 $flag = 1; 52 print; 53 } elsif (/^CHARS\s+(\d+)/) { 54 $max_chars = $1; 55 print; 56 } elsif (/\S/) { 57 print; 58 } 59} 60 61# clear progress bar 62print STDERR "\r" . (" " x ($col - 1)) . "\r" if ($verbose != 0); 63 64if ($ch_count != $max_chars) { 65 print STDERR 66 "'CHARS' line in $ARGV says that $max_chars glyphs are included,\n", 67 "but actual number of glyphs are $ch_count. check and correct.\n"; 68 exit 1; 69} else { 70 exit 0; 71} 72