unlink "$WORKDIR/$WORKNAME.ttf";
mkdir "$WORKDIR/build";
+open LOG, ">>:utf8", "$WORKDIR/$WORKNAME.log";
+select((select(LOG), $| = 1)[0]);
+
# initialize
if(-e "$WORKDIR/$HEADER_FILENAME"){
open FH, "<:utf8", "$WORKDIR/$HEADER_FILENAME";
}
close FH;
close FH2;
+
+ print LOG "Prepare header file ... done.\n";
}
else{
- open FH, ">>:utf8", "$WORKDIR/$WORKNAME.log";
- print FH "No header file.\n";
- close FH;
+ print LOG "No header file.\n";
+ close LOG;
exit;
}
}
close FH;
$temp = $buffer;
+
+ print LOG "Prepare parts file ... done.\n";
}
else{
- open FH, ">>:utf8", "$WORKDIR/$WORKNAME.log";
- print FH "No parts file.\n";
- close FH;
+ print LOG "No parts file.\n";
+ close LOG;
exit;
}
@temp = split(/\r\n|\r|\n/, $temp);
$buhin{$temp2[0]} = $temp2[1];
}
}
+print LOG "Prepare parts data ... done.\n";
-# parse target codepoint
+# parse target code point
%target = ();
foreach(sort(keys %buhin)){
if($_ =~ m/^\[([^\]])\]$/){
$name = $_;
$target{$target} = $name;
}
+print LOG "Prepare target code point ... done.\n";
# make glyph for each target
+print LOG "Prepare each glyph.\n";
foreach(sort(keys(%target))){
$code = $_;
- $target = $target{$_};
+ print LOG "$code : ";
+ $target = $target{$code};
%subset = ();
&addsubset($target);
$partsdata = "";
$partsdata =~ s/([^0-9A-Za-z_ ])/'%'.unpack('H2',$1)/ge;
$partsdata =~ s/\s/+/g;
$svg = `$MAKEGLYPH $target $partsdata $SHOTAI $WEIGHT`;
+ print LOG "$MAKEGLYPH $target $partsdata $SHOTAI $WEIGHT\n";
open FH, ">$WORKDIR/build/$code.svg";
print FH $svg;
close FH;
&addglyph($code);
}
+print LOG "Prepare each glyph ... done.\n";
# scripts footer
if(-e "$WORKDIR/$FOOTER_FILENAME"){
}
close FH;
close FH2;
+
+ print LOG "Prepare footer file ... done.\n";
}
else{
- open FH, ">>:utf8", "$WORKDIR/$WORKNAME.log";
- print FH "No footer file.\n";
- close FH;
+ print LOG "No footer file.\n";
+ close LOG;
exit;
}
+close LOG;
&makefont;
+##############################################################################
+
sub addglyph{
- my $buffer =<<"EOT";
+ my $buffer =<<"EOT";
Print(0u$_[0])
Select(0u$_[0])
Clear()
close FH;
}
+##############################################################################
+
sub makefont{
- my $buffer = "Generate(\"$WORKDIR/$TEMPNAME.ttf\", \"\", 0)\n";
+ my $buffer = "Generate(\"$WORKDIR/$WORKNAME.ttf\", \"\", 0)\n";
$buffer .= "Quit()\n";
open FH, ">>:utf8", "$WORKDIR/$WORKNAME.scr";
print FH $buffer;
close FH;
- $buffer = `$FONTFORGE -script $WORKDIR/$WORKNAME.scr > $WORKDIR/$WORKNAME.log 2>&1`;
- $buffer = `$MV $WORKDIR/$TEMPNAME.ttf $WORKDIR/$WORKNAME.ttf`;
+ $buffer = `export LANG=utf-8; $FONTFORGE -script $WORKDIR/$WORKNAME.scr >> $WORKDIR/$WORKNAME.log 2>&1`;
}
+##############################################################################
+
sub addsubset{
$subset{$_[0]} = $buhin{$_[0]};
- while($buhin{$_[0]} =~ m/(^|\$)99:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:(.+?)(\$|$)/gc){
- if(!exists($subset{$2})){
- &addsubset($2);
+ my $buffer = '$'.$buhin{$_[0]}.'$';
+ while($buffer =~ m/\$99:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:([^\$]*)/gc){
+ if(!exists($subset{$1})){
+ &addsubset($1);
}
}
}
+##############################################################################