/usr/bin/dumppsf is in console-cyrillic 0.9-17.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | #!/usr/bin/perl
# see perldoc dumppsf for complete documentation
open F,$ARGV[0] or die "Cannot open font file $ARGV[0]";
read F,$header,4;
($c1,$c2,$mode,$charsize) = unpack "C4",$header;
unless ($c1==0x36 && $c2== 0x04) {
print STDERR "Not a psf format, trying to interpret as raw font\n";
seek(F,0,2);
$size=tell(F);
if ($size % 256!=0) {
die "Size is not multiply of 256. Probably non-raw font file";
} else {
$charsize = $size/256;
print STDERR "Doing ",$charsize," scan-line font\n";
}
seek(F,0,0);
} else {
print STDERR "PSF mode $mode, charsize=$charsize\n";
if ($mode==0 || $mode==2) {
$fontsize=256;
} elsif ($mode==1 || $mode==3) {
$size=512;
} else {
print STDERR "Unknown psf mode $mode. May be you'll have more luck with psfgettable\n";
exit 1;
}
if ($mode >=2) {
# getting unicode table;
seek(F,4+$fontsize*$charsize,0);
print STDERR "Read ",read (F,$table,10000000),"bytes of unicode table\n";
$i=0;
for $j (unpack "v*",$table) {
if ($j==0xFFFF) {
$i++; next;
}
if ($unicode[$i]) {
push @{$unicode[$i]},$j;
} else {
$unicode[$i]=[$j];
}
}
seek F,4,0;
}
}
for ($i=0;$i<$fontsize;$i++) {
read F,$char,$charsize;
print "Character: $i";
if ($unicode[$i]) {
print " Unicode chars: ",
join(" ",(map {sprintf("U+%04X",$_)} @{$unicode[$i]}));
}
print "\n";
for $j (unpack "C*", $char) {
for ($k=128;$k;$k>>=1) {
print (($k & $j)?"*":" ");
}
print "\n";
}
}
=head1 NAME dumppsf
converts psf file to readable ASCII file.
=head1 SYNOPSIS
dumppsf fontfile
=head1 DESCRIPTION
This script takes psf font with unicode mapping as an argument, and
produces text file where all characters from this font are represented
graphically. It allows to preview Linux console font even there is no
Linux console around.
=head1 BUGS
No undumppsf script is written yet, so it is impossible to edit ASCII
representation of font and convert back
=head1 SEE ALSO
B<displayfont>(1), B<raw2psf>(1), B<consolechars>(1)
=head1 COPYRIGHT
Public domain. Maide on Earth.
=head1 AUTHOR
Victor Wagner E<lt>vitus@ice.ruE<gt>
|