--- loncom/homework/convertjme.pl 2005/01/31 21:55:44 1.11 +++ loncom/homework/convertjme.pl 2011/07/04 09:24:54 1.16 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # Dynamically converts JME strings into either a png or ps file. # -# $Id: convertjme.pl,v 1.11 2005/01/31 21:55:44 albertel Exp $ +# $Id: convertjme.pl,v 1.16 2011/07/04 09:24:54 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -34,8 +34,8 @@ use strict; ### For standalone operation, set $loncapa to 0, and comment out both uses my $loncapa=1; use lib '/home/httpd/lib/perl'; -use LONCAPA::loncgi(); - +use LONCAPA::loncgi; +use LONCAPA; use GD; use PostScript::Simple; @@ -66,11 +66,11 @@ sub unescape { my ($id,$width,$ps,$png,@JMEstring); if ($loncapa) { $id=$ENV{'QUERY_STRING'}; - $width = $ENV{'cgi.'.$id.'.WIDTH'}; + $width = $Apache::lonnet::env{'cgi.'.$id.'.WIDTH'}; if (!$width) { $width = 400; } - $png = $ENV{'cgi.'.$id.'.PNG'}; - $ps = $ENV{'cgi.'.$id.'.PS'}; - @JMEstring=&unescape($ENV{'cgi.'.$id.'.JME'}); + $png = $Apache::lonnet::env{'cgi.'.$id.'.PNG'}; + $ps = $Apache::lonnet::env{'cgi.'.$id.'.PS'}; + @JMEstring=&unescape($Apache::lonnet::env{'cgi.'.$id.'.JME'}); } else { @JMEstring = @ARGV; $width = shift @JMEstring; @@ -137,7 +137,7 @@ if ($png) { my %electrons = ("C",4,"N",5,"P",5,"O",6,"S",6); my %font_width = (" ",250,"+",564,"-",500,"0",500,"1",500,"2",500,"3",500,"4",500,"5",500,"6",500,"7",500,"8",500,"9",500,"A",722,"B",667,"C",667,"D",722,"E",611,"F",556,"G",722,"H",722,"I",333,"J",389,"K",722,"L",611,"M",889,"N",722,"O",722,"P",556,"Q",722,"R",667,"S",556,"T",611,"U",722,"V",722,"W",944,"X",722,"Y",722,"Z",611,"a",444,"b",500,"c",444,"d",500,"e",444,"f",333,"g",500,"h",500,"i",278,"j",278,"k",500,"l",278,"m",778,"n",500,"o",500,"p",500,"q",500,"r",333,"s",389,"t",278,"u",500,"v",500,"w",722,"x",500,"y",500,"z",444); -my $font = '/usr/share/fonts/default/Type1/n021003l.pfb'; +my $font = '/home/httpd/html/adm/fonts/DejaVuSerif-Roman.ttf'; my $pointsize = 20; my ($ptsize,@bounds); if ($png) { @@ -396,7 +396,7 @@ foreach my $struct (@all_structs) { (shift @formula) =~ /([A-Z][a-z]?)(\d*)/; my $carrige = $x[$i]-stringWidth($1)/2; $carrige = printElement ($1,$2,$carrige,$y[$i]); - my $y = (@formula > 0) ? $y[$i] + fm2cm(800) : $y[$i]; + my $y = (@formula > 0) ? $y[$i] + fm2cm(900) : $y[$i]; $carrige = (@formula > 0) ? $x[$i]-stringWidth($1)/2 : $carrige; foreach (@formula) { @@ -409,7 +409,7 @@ foreach my $struct (@all_structs) { (shift @formula) =~ /([A-Z][a-z]?)(\d*)/; my $carrige = $x[$i]-stringWidth($1)/2; $carrige = printElement ($1,$2,$carrige,$y[$i]); - my $y = (@formula > 0) ? $y[$i] + fm2cm(-800) : $y[$i]; + my $y = (@formula > 0) ? $y[$i] + fm2cm(-900) : $y[$i]; $carrige = (@formula > 0) ? $x[$i]-stringWidth($1)/2 : $carrige; foreach (@formula) { @@ -431,7 +431,7 @@ if ($loncapa) { print "Content-type: image/png\n\n"; print $im->png; } elsif ($ps) { - my $psfile = "/home/httpd/perl/tmp/".$id.'.eps'; + my $psfile = LONCAPA::tempdir().$id.'.eps'; $im->output($psfile); print "Content-type: text/html\n\n"; print (<