use strict; my($in,$adm,$var,$con,$cok) = @{$::root}{qw(in adm var con cok)}; sub A03() { use Imager::DTP::Textbox::Horizontal; use Imager::DTP::Textbox::Vertical; use utf8; use Jcode; my $im = Imager->new(xsize=>650,ysize=>500,channels=>3); $im->box(filled=>1,color=>'#FFFFFF'); $im->box(filled=>0,color=>'#CCCCCC'); my $text = 'text will be drawn here'; $text = $in->{text} if($in->{text} ne ''); # change text encoding to utf8 if(!&utf8::is_utf8($text)){ my($code) = &Jcode::getcode($text); $text = Jcode->new($text,$code)->utf8; &utf8::decode($text); } my $fface = ($in->{fontface})? $con->{fontface}{$in->{lang}}{$in->{fontface}} : "Futura.TTF"; my $path = "$con->{srcdir}/others/$fface"; my $fontsize = ($in->{fontsize})? $in->{fontsize} : 14; my $font; if($in->{lang} eq 'JA' && $in->{fontface} =~ /^[12]$/){ my $i; if ($in->{fontface} == 1){ $i=0 } elsif($in->{fontface} == 2){ $i=1 } $font = Imager::Font->new(file=>$path,type=>'ft2',aa=>1,utf8=>1, size=>$fontsize,color=>'#000000',index=>$i) or die $Imager::ERRSTR; }else{ $font = Imager::Font->new(file=>$path,type=>'ft2',aa=>1,utf8=>1, size=>$fontsize,color=>'#000000') or die $Imager::ERRSTR; } my $tb; if($in->{direction} eq 'v'){ $tb = Imager::DTP::Textbox::Vertical->new(); }else{ $tb = Imager::DTP::Textbox::Horizontal->new(); } $tb->setText(text=>$text,font=>$font); $tb->setWspace(pixel=>$in->{wspace}) if($in->{wspace}); $tb->setLeading(percent=>$in->{leading}) if($in->{leading}); $tb->setAlign(halign=>$in->{halign}) if($in->{halign}); $tb->setAlign(valign=>$in->{valign}) if($in->{valign}); $tb->setWrap(width=>$in->{wrapwidth}) if($in->{wrapwidth} ne ''); $tb->setWrap(height=>$in->{wrapheight}) if($in->{wrapheight} ne ''); $tb->setLetterScale(x=>$in->{xscale}) if($in->{xscale}); $tb->setLetterScale(y=>$in->{yscale}) if($in->{yscale}); #Dumpvalue::HTML->new(charset=>"utf-8")->dumpValue($tb); my $debug = ($in->{debug} eq 'on')? 1 : 0; $tb->draw(target=>$im,x=>325,y=>250,debug=>$debug); $im->box(filled=>1,xmin=>324,ymin=>249,xmax=>326,ymax=>251,color=>'#880000'); &Misc::OutImage($im,$adm); } package Misc; use strict; sub OutImage ($$){ my($p,$adm) = @_; $adm->{no_header} = 1; $adm->{debug} = 0; print "Content-Type: image/jpeg\n\n"; return $p->write(fd=>fileno(STDOUT),type=>'jpeg',jpegquality=>90) or die $p->errstr; }