From e3f8ab98c8b50c47c3801b480055001ef6b6b1ba Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Tue, 5 Jul 2011 15:23:19 +0200 Subject: [PATCH] Enhance makefont.pl, for pixel-painted art ".xbdf" --- tools/font/makefont.pl | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/tools/font/makefont.pl b/tools/font/makefont.pl index 777e359..591d8dd 100755 --- a/tools/font/makefont.pl +++ b/tools/font/makefont.pl @@ -29,12 +29,11 @@ $|=1; my @charlist=(32..126,0x20ac); #,0x3044 # hiragana I push @charlist,map {ord $_} qw(ä ö ü Ä Ö Ü ß); - ### ### Runtime Options ### -my ($verbose,$raw); +my ($verbose,$raw,$chars); my $size=18; my $font="ttf/Ubuntu-Regular.ttf"; @@ -43,6 +42,7 @@ GetOptions ("size=i" => \$size, # numeric "font=s" => \$font, # string "verbose" => \$verbose, # flag "raw" => \$raw, # flag + "chars=s" => \$chars, # list of chars "help" => sub { print <){ chomp; /^ENDCHAR/ && do { + $bbh=$#bchar+1 if !$bbh; warn "Char $ccode has strange height?\n" if ($#bchar+1 != $bbh); for (1..$bby){ push @bchar,("0"x$bbw); @@ -564,8 +569,18 @@ sub init_bdf{ @bchar=(); }; if($inchar){ - my $x=unpack("B*",pack("H*",$_)); - $x=substr($x,0,$bbw); + my $x; + if($inchar==2){ + $x=$_; + $x=~y/ ./0/; + $x=~y/xX\*/1/; + $x=~y/01//cd; + next if($x eq ""); + $bbw=length($x) if !$bbw; + }else{ + $x=unpack("B*",pack("H*",$_)); + $x=substr($x,0,$bbw); + }; push @bchar,$x; # $x=~y/01/ */; # print $x,"\n"; @@ -573,6 +588,7 @@ sub init_bdf{ }; /^BITMAP/ && do {$inchar=1;}; + /^XBITMAP/ && do {$inchar=2;($bbw,$bbh,$bbx,$bby)=(0)x4;}; /^ENCODING (.*)/ && do {$ccode=$1; }; /^BBX (\d+) (\d+) (\d+) ([-\d]+)/ && do {$bbw=$1;$bbh=$2;$bbx=$3;$bby=$4;}; };