From d84f6484779a1557ea0a305075a7ce67cc86ce93 Mon Sep 17 00:00:00 2001 From: imiyazaki Date: Wed, 22 Mar 2006 13:32:03 +0000 Subject: [PATCH] use new KAGE server. use EPS format. --- makefonts.pl | 75 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/makefonts.pl b/makefonts.pl index 51274b8..5b909ef 100755 --- a/makefonts.pl +++ b/makefonts.pl @@ -10,16 +10,16 @@ use Chise_utils '$omegadb_path'; require 5.008001; #my $kageaddr="home.fonts.jp:5100"; # Specify port number! -my $kageaddr="fonts.jp:80"; # Specify port number! +#my $kageaddr="fonts.jp:80"; # Specify port number! #my $kagecgi="/~kamichi/test/kagecgi.cgi"; # -my $kagecgi="v0.4/engine/kage.cgi"; # -#my $kageaddr="localhost:80"; # Specify port number! -#my $kagecgi="cgi-bin/kage.cgi"; # +#my $kagecgi="v0.4/engine/kage.cgi"; # +my $kageaddr="localhost:80"; # Specify port number! +my $kagecgi="cgi-bin/kage.cgi"; # my $t1asm = "/usr/bin/env t1asm"; # point to 't1asm' executable. #die "Cannot execute $t1asm. Abort.\n" unless -x $t1asm; #my $pfaedit="/usr/bin/env pfaedit"; # point to 'pfaedit' executable. -my $pfaedit="/usr/bin/env fontforge"; # point to 'pfaedit' executable. +my $pfaedit="/usr/bin/env fontforge"; # point to 'fontforge' executable. #die "Cannot execute $pfaedit. Abort.\n" unless -x $pfaedit; $omegadb_path=~s!/$!!; @@ -27,7 +27,9 @@ $omegadb_path=~s!/$!!; my $cleanup_script=""; # Check the path of pfaedit script, if needed. unless($cleanup_script){ - if(-e "/usr/local/share/texmf/omega/ocp/local/chise/svg2t1.pfe"){ + if(-e "/usr/local/share/texmf/omega/ocp/chise_rqd/chise/svg2t1.pfe"){ + $cleanup_script="/usr/local/share/texmf/omega/ocp/chise_rqd/chise/svg2t1.pfe"; + }elsif(-e "/usr/local/share/texmf/omega/ocp/local/chise/svg2t1.pfe"){ $cleanup_script="/usr/local/share/texmf/omega/ocp/local/chise/svg2t1.pfe"; }elsif(-e "/usr/share/texmf/omega/ocp/local/chise/svg2t1.pfe"){ $cleanup_script="/usr/share/texmf/omega/ocp/local/chise/svg2t1.pfe"; @@ -108,35 +110,34 @@ cleartomark FOOTER } -# Convert svg to Type1 charstring. +# Convert eps to Type1 charstring. # Return: Type1 charstring. -sub svg2charstring { - my ($svg) = @_; - $svg=~s/>\n/; - my $path = $1; $path =~ s/^ +//; $path =~ s/ +$//; - my @point_pair = split(/ /, $path); - ($x1, $y1) = split(/,/, shift(@point_pair)); - $y1=1000-$y1-100; - if(defined $x2){ - $glyph.=sprintf("%d %d rmoveto\n", $x1-$x2, $y1-$y2); - }else{ - $glyph.= "$x1 $y1 rmoveto\n"; + next if(/^%/); + if(m/([\-\d]+)\s+([\-\d]+)\s+moveto/){ + $x1=$1; $y1=$2; $y1=$y1+100; + if(defined $x2){ + $glyph.=sprintf("%d %d rmoveto\n",$x1-$x2,$y1-$y2); + }else{ + $glyph.="$x1 $y1 rmoveto\n"; + } } - foreach my $pair (@point_pair) { - ($x2, $y2) = split(/,/, $pair); - $y2=1000-$y2-100; - $glyph.=sprintf("%d %d rlineto\n", $x2-$x1, $y2-$y1); - $x1=$x2; $y1=$y2; + elsif(m/([\-\d]+)\s+([\-\d]+)\s+lineto/){ + $x2=$1; $y2=$2; $y2=$y2+100; + $glyph.=sprintf("%d %d rlineto\n",$x2-$x1,$y2-$y1); + $x1=$x2,$y1=$y2; + } + elsif(/closepath/){ + $glyph.="closepath\n"; } - $glyph.= "closepath\n"; } return $glyph.= "endchar\n\} |-\n"; } @@ -163,18 +164,18 @@ BLACKBOX # Note: # Referene passing destroys the original array! my $request="$req.$suffix"; - my ($svg, $charstring); + my ($eps, $charstring); my $char = sprintf("ch%03d", $charnum); - if(defined $db && $db->db_get($request, $svg)==0){ + if(defined $db && $db->db_get($request, $eps)==0){ # If glyph is already in DB, then use it. - $charstring = svg2charstring($svg); + $charstring = eps2charstring($eps); print STDERR "Use cached glyph for $request.\n"; }else{ # If glyph is not yet in DB, query KAGE server. my $kageserver; my $location; # For redirection if($kageserver = IO::Socket::INET->new("$kageaddr")){ - print $kageserver "GET /$kagecgi?$req&shotai=$suffix&type=svg\r\n"; + print $kageserver "GET /$kagecgi?$req&shotai=$suffix&type=eps\r\n"; # print $kageserver "HEAD /$kagecgi?$req&shotai=$suffix&type=svg HTTP/1.1\r\n"; # print $kageserver "Host: $kageaddr\r\n\r\n"; # #Get redirection info. @@ -189,19 +190,19 @@ BLACKBOX # and $kageserver=IO::Socket::INET->new($location)){ # print $kageserver "GET /$request.svg HTTP/1.1\r\n"; # print $kageserver "Host: $location\r\n\r\n"; - local $/; $svg=<$kageserver>; + local $/; $eps=<$kageserver>; close($kageserver); - $svg =~ s/\r//gm; # remove CR. - $svg =~ s/^.+\n\n//ms; # remove HTTP header. + $eps =~ s/\r//gm; # remove CR. + $eps =~ s/^.+\n\n//ms; # remove HTTP header. # }else{ -# $svg="error"; +# $eps="error"; # } }else{ print STDERR "Cannot connect to KAGE server at $kageaddr.\n"; - $svg="error"; + $eps="error"; } - if($charstring = svg2charstring($svg)){ - if(defined $db && $db->db_put($request, $svg)==0){ + if($charstring = eps2charstring($eps)){ + if(defined $db && $db->db_put($request, $eps)==0){ # If glyph request is successful, then store it to DB. print STDERR "Glyph for $request cached.\n"; } -- 1.7.10.4