(chise-tex-encode-region-for-jis): Don't decompose <CYRILLIC SMALL
[chise/omega.git] / makefonts.pl
index ebb7dc3..51274b8 100755 (executable)
@@ -6,22 +6,41 @@ use strict;
 use utf8;
 use IO::Socket::INET;
 use BerkeleyDB;
+use Chise_utils '$omegadb_path';
 require 5.008001;
 
-my $omegadb_path="/usr/local/lib/chise/omega"; # set to the path of your db and script.
-
 #my $kageaddr="home.fonts.jp:5100"; # Specify port number!
-my $kageaddr="home.fonts.jp:5101"; # 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 $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 pfaedit"; # point to 'pfaedit' executable.
+my $pfaedit="/usr/bin/env fontforge"; # point to 'pfaedit' executable.
 #die "Cannot execute $pfaedit. Abort.\n" unless -x $pfaedit;
 
 $omegadb_path=~s!/$!!;
 
-my $cleanup_script="$omegadb_path/svg2t1.pfe"; # Check the path of pfaedit script.
+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"){
+       $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";
+    }elsif(-e "/sw/share/texmf/omega/ocp/local/chise/svg2t1.pfe"){
+       $cleanup_script="/sw/share/texmf/omega/ocp/local/chise/svg2t1.pfe";
+    }
+}
+unless($cleanup_script and -e $cleanup_script){
+    print STDERR "svg2t1.pfe not found!\n",
+    "please check \$cleanup_script in $0.\n";
+    exit 1;
+}
+
 my $dbpath="$omegadb_path/glyph.db"; # check your DB path.
 
 # Open Glyph Database
@@ -93,11 +112,12 @@ FOOTER
 # Return: Type1 charstring.
 sub svg2charstring {
     my ($svg) = @_;
+    $svg=~s/></>\n</g;
     my @paths= split(/\n/, $svg);
     my ($x1, $y1, $x2, $y2);
     my $glyph= "\{\n0 1000 hsbw\n";
     for (@paths){
-       if(m/error/i){
+       if(m/error/i or m/bad/i){
            return undef;
        }
        next unless /\<path d=\"M([0-9, ]+)Z\"\/\>/;
@@ -154,8 +174,9 @@ BLACKBOX
             my $kageserver;
             my $location; # For redirection
             if($kageserver = IO::Socket::INET->new("$kageaddr")){
-                print $kageserver "HEAD /$request.svg HTTP/1.1\r\n";
-                print $kageserver "Host: $kageaddr\r\n\r\n";
+                print $kageserver "GET /$kagecgi?$req&shotai=$suffix&type=svg\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.
 #               local $/="\r\n";
 #               while(<$kageserver>){
@@ -203,14 +224,19 @@ BLACKBOX
 ##############
 
 # Read ids data generated by inCHISE
-my $idsdata="$omegadb_path/idsdata.pl";
+my $idsdata="$omegadb_path/idsdata.txt";
 my ($font_start, $ids_start, %ids);
 if(-e $idsdata){
     # "require" doesn't work well.
     # I don't know why...
     open (my $data, "<:utf8","$idsdata");
     while(<$data>){
-       eval $_;
+       utf8::decode($_);
+       if(m/^START\t(\d+)\t(\d+)/){
+           $font_start=$1,$ids_start=$2;
+       }elsif(m/^(.*?)\t(\d+)\t(\d+)/){
+           $ids{$1}=[$2,$3,];
+       }
     }
     close($data);
 }else{
@@ -237,9 +263,12 @@ foreach my $key (keys %ids){
            last;
        }
     }
+    $code=~s/(.)u/$1.u/g;
     $Requests[$ids{$key}[0]]->[$ids{$key}[1]]=$code;
 }
 
+print STDERR "Sending query to KAGE server at $kageaddr.\n";
+
 # Create fonts.
 foreach my $fontnum (0 .. $#Requests){
     my @faces=(['Mincho', 'min', 'mincho'],