X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=makettf%2Fmakettf.cgi;h=d259910474dab302ae05ff676534c6bc0fe91922;hb=26a842dd448327643b89f2b681ac5b3c600722da;hp=b7fa8efe0f9fec2179fe26e46893392bd4e5dd3c;hpb=0477dd600471ebf632d50ce4125e4f33f2f8b83d;p=chise%2Fkage.git
diff --git a/makettf/makettf.cgi b/makettf/makettf.cgi
index b7fa8ef..d259910 100755
--- a/makettf/makettf.cgi
+++ b/makettf/makettf.cgi
@@ -1,39 +1,60 @@
#!/usr/bin/perl
+
+# definition
+$BASEDIR = "/var/www/makettf";
+$MAKETTF = "/usr/bin/perl $BASEDIR/makettf.pl";
+$LICENSE = 'Created by KAGE system. (http://fonts.jp/)';
+$TEMP="font";
+$HEADER_FILENAME = "head.txt";
+$PARTS_FILENAME = "parts.txt";
+$FOOTER_FILENAME = "foot.txt";
+
+# initialize
use utf8;
binmode STDOUT, ":utf8";
-
use CGI;
$form = new CGI;
-$PERL = "/usr/bin/perl";
-$RM = "/bin/rm";
-$LICENSE = 'Created by KAGE system. (http://fonts.jp/)';
-$TEMP="temp";
-
-$RANDOM = sprintf("%05X", rand() * 0x100000);
-$TEMPDIR = "/tmp/makettf_$RANDOM";
+# prepare working directory
+$RANDOM = sprintf("%07X", rand(0x10000000));
+$TEMPDIR = "$BASEDIR/$RANDOM";
+$TEMPURL = "$RANDOM";
mkdir($TEMPDIR);
-&makehead();
-&makefoot();
-&makeparts();
-$dummy = `$PERL makettf.pl $TEMPDIR $TEMP mincho 3`;
-&sendfont();
+# main : divided for parent and child process
+$| = 1;
+$pid = fork();
+unless(defined $pid){
+ &makeerror();
+ exit;
+}
+if($pid > 0){
+ &makepage();
+} else{
+ close(STDIN);
+ close(STDOUT);
+ close(STDERR);
+ &makehead();
+ &makefoot();
+ &makeparts();
+ $dummy = `$MAKETTF $TEMPDIR $TEMP mincho 3`;
+}
+exit;
sub makehead{
- $fontname_en = $form->param('fontname-en');
- $fontname_en =~ s/[\;\&\#\"\'\%\\\$\:\!\=\~\^\`]//g;
- $fontname_ja = $form->param('fontname-ja');
- $fontname_ja =~ s/[\;\&\#\"\'\%\\\$\:\!\=\~\^\`]//g;
- utf8::decode($fontname_ja);
- if($fontname_en eq ""){
- $fontname_en = "Untitled";
- }
- if($fontname_ja eq ""){
- $fontname_ja = $fontname_en;
- }
- open FH, ">:utf8", "$TEMPDIR/head.txt";
- print FH <<"EOT";
+ $fontname_en = $form->param('fontname-en');
+ $fontname_en =~ s/[\;\&\#\"\'\%\\\$\:\!\=\~\^\`]//g;
+ $fontname_ja = $form->param('fontname-ja');
+ $fontname_ja =~ s/[\;\&\#\"\'\%\\\$\:\!\=\~\^\`]//g;
+ utf8::decode($fontname_ja);
+ if($fontname_en eq ""){
+ $fontname_en = "Untitled";
+ }
+ if($fontname_ja eq ""){
+ $fontname_ja = $fontname_en;
+ }
+ open FH, ">:utf8", "$TEMPDIR/$HEADER_FILENAME";
+ print FH <<"EOT";
New()
Reencode("UnicodeFull")
SetTTFName(0x409,0,"$LICENSE")
@@ -42,40 +63,71 @@ SetTTFName(0x409,4,"$fontname_en")
SetTTFName(0x411,1,"$fontname_ja")
SetTTFName(0x411,4,"$fontname_ja")
EOT
- close FH;
+ close FH;
}
sub makefoot{
- open FH, ">:utf8", "$TEMPDIR/foot.txt";
- close FH;
+ open FH, ">:utf8", "$TEMPDIR/$FOOTER_FILENAME";
+ close FH;
}
sub makeparts{
- my $temp = $form->param('partsdata');
- utf8::decode($temp);
- open FH, ">:utf8", "$TEMPDIR/parts.txt";
- print FH $temp;
- close FH;
+ my $temp = $form->param('partsdata');
+ utf8::decode($temp);
+ open FH, ">:utf8", "$TEMPDIR/$PARTS_FILENAME";
+ print FH $temp;
+ close FH;
+}
+
+sub makepage{
+ print <<"EOT";
+Content-type: text/html;
+
+
+
+
+
+
+ãã©ã³ããã¦ã³ãã¼ã
+
+
+
+
ãã©ã³ãçæä¸
+
以ä¸ã®ãªã³ã¯ãã¯ãªãã¯ãã¦ãã ããããªã³ã¯ãåãã¦ããå ´åã¯çæä¸ã§ãã®ã§ããå°ããå¾
ã¡ãã ããã6000ã°ãªãã§25åç¨åº¦ãããã¾ãã
+
ãã©ã³ãã®ãã¦ã³ãã¼ã
+
çæãã°ï¼ãã°ããããã¨ãããã«å¦çããã°ãªãã®UCSã³ã¼ããã¤ã³ããè¨é²ããã¾ããé常ã®æ¼¢åã¯0u4E00ãã0u9FA5ã®éã§ã0u4E00ããå¦çããã¾ãã0u9XXXã¾ã§å°éããã«æ´æ°ãæ¢ã¾ã£ãå ´åã¯ãã¼ã¿ã«ã¨ã©ã¼ããã失æãã¦ããå¯è½æ§ãããã¾ãã
+
æ»ã
+
+fonts.jp
+
+
+
+EOT
}
-sub sendfont{
- my $fdata = "";
- my $fsize = 0;
- my @bdata;
- print <<"EOT";
-Content-type: application/octet-stream
-Content-Disposition: attachment; filename = $fontname_en.ttf
+sub makeerror{
+print <<"EOT";
+Content-type: text/html;
+
+
+
+
+
+
+ãã©ã³ãçæ失æ
+
+
+
+
ãã©ã³ãçæ失æ
+
ããä¸åº¦æ»ã£ã¦ããç´ãã¦ãã ããã
+
æ»ã
+
+fonts.jp
+
+
+
EOT
- open FH, "<:utf8", "$TEMPDIR/$TEMP.ttf";
- while(1){
- $readed = read FH, $fdata, 1024;
- utf8::decode($fdata);
- print $fdata;
- if($readed <= 0){
- last;
- }
- }
- close FH;
- $dummy = `$RM -r $TEMPDIR`;
}