File: bit2bdf

package info (click to toggle)
xfonts-mona 2.90-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 7,888 kB
  • sloc: perl: 11,238; makefile: 442; lisp: 68
file content (71 lines) | stat: -rwxr-xr-x 1,583 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env perl
# $Id: bit2bdf,v 1.2 2002/09/14 20:34:39 euske Exp $
# This is a help script to converting font_src.bit to bdf.
#
#	programmed by KANOU Hiroki <kanou@mil.allnet.ne.jp>
#	modified by Yasuyuki Furukawa <Furukawa.Yasuyuki@fujixerox.co.jp>
#      
#			* public domain *
#

$verbose = 0;
$verbose_min = 100;

@vmeter = ("|", "\\", "-", "/");

for $opt (@ARGV) {
    if ($opt =~ /^-/) {	# option
	$verbose = 1 if $opt eq '-V';	# verbose
	next;
    } else {
	$file = $opt;
	last;
    }
}

if ($verbose) {
    $col = int(`stty  size 2>/dev/null | sed 's/.* //'`) || 80;
}

$file= "-" unless $file;
$ch_count = 0;
open F, $file || die;

while (<F>) {
    if (/^ENDCHAR/) {
	$flag = 0;
	s/\s*#.*//;
	print;
	if (($ch_count++ % 100) == 0 && $verbose != 0 && $max_chars > $verbose_min) {
	    $n = int($ch_count * 100 / $max_chars);
	    $m = int($n * ($col - 21) / 100);
	    $l = $col - 20 - $m;
	    print STDERR "\rprogress|". ("=" x $m). (" " x $l). "$n\%".
		         $vmeter[$ch_count2++ % 4];
	}
    } elsif ($flag == 1) {
        chomp;
	tr/pPOo@:;,\\\/./#####       /;
	print unpack("H*", pack("B*", $_)), "\n";
    } elsif (/^BITMAP/) {
	$flag = 1;
	print;
    } elsif (/^CHARS\s+(\d+)/) {
	$max_chars = $1;
	print;
    } elsif (/\S/) {
	print;
    }
}

# clear progress bar
print STDERR "\r" . (" " x ($col - 1)) . "\r" if ($verbose != 0);

if ($ch_count != $max_chars) {
    print STDERR 
	"'CHARS' line in $ARGV says that $max_chars glyphs are included,\n",
	"but actual number of glyphs are $ch_count. check and correct.\n";
    exit 1;
} else {
    exit 0;
}