Mercurial > hg > Applications > 14x14ja
view ascii2bdf.pl @ 0:a6ddaa18e3c1
k14 unicode font kit
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 15 Jun 2013 12:23:00 +0900 |
parents | |
children | 7f5d4dad9d6b |
line wrap: on
line source
#!/usr/bin/perl use strict; my ($name,$encoding,@bitmap); #while(<>) { # last if (/^ENDPROP/); #} #my $dum = <>; # skip CHARS my ($lineno,$line); my $width; my $height; while(<>) { if(/^STARTCHAR\s+(.*)/) { &init(); $name=$1; print; } elsif (/^ENCODING\s+(\d+)/) { $encoding=$1; print; } elsif (/^SWIDTH (\d+) (\d+)/) { print; } elsif (/^DWIDTH (\d+) (\d+)/) { $width = $1; print; } elsif (/^BBX ([-+\d]+) ([-+\d]+) ([-+\d]+) ([-+\d]+)/) { print; $height = $2; } elsif (/^BITMAP/) { print; $line = $lineno+2; # error line must start 1 } elsif (/^ENDCHAR/) { &display(); print "ENDCHAR\n"; } elsif (/^[ *]+$/) { chop; push(@bitmap,$_); } $lineno++; } sub display { my $hwidth = int((($width+7)&(~7))/4); # print "hwdith $hwidth\n"; my $i = 0; for my $hex (@bitmap) { my $bin; my $orig = $hex; my $j = 0; while($hex =~ s/..//) { if ($& eq " ") { $bin .= "0"; } elsif ($& eq "**") { $bin .= "1"; } else { print $line+$i,": Error Bad Alignment ","| "x$width,"\n"; print $line+$i,": Error Bad Alignment ","$orig\n"; last; } if ($j++ > $width) { print $line+$i,": Error Too long",substr($orig,$j), "|$hex too long \n" if ($hex =~ /[^ ]/); last; } } # print "bitmap $bin -- $i\n"; my $h = pack("B*",$bin . "0"x$width); my $b = unpack("H*",$h); $b = substr($b,0,$hwidth); print "$b\n"; last if ($i++ > $height-2); } # print "hhhh $height-$i = ",$height-$i,"\n"; print (("0"x$hwidth."\n")x($height-$i)) if ($height-$i > 0); } sub init { $name = ''; $encoding = 0; @bitmap= (); } # end