[LON-CAPA-cvs] cvs: loncom /xml lonplot.pm

matthew lon-capa-cvs@mail.lon-capa.org
Fri, 24 Oct 2003 17:35:33 -0000


matthew		Fri Oct 24 13:35:33 2003 EDT

  Modified files:              
    /loncom/xml	lonplot.pm 
  Log:
  Better TeX font support - allow users to specify the size of the font
  used when the eps file is generated.  Ought to be case insensitive.
  
  
Index: loncom/xml/lonplot.pm
diff -u loncom/xml/lonplot.pm:1.91 loncom/xml/lonplot.pm:1.92
--- loncom/xml/lonplot.pm:1.91	Sat Sep 27 00:08:56 2003
+++ loncom/xml/lonplot.pm	Fri Oct 24 13:35:32 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Dynamic plot
 #
-# $Id: lonplot.pm,v 1.91 2003/09/27 04:08:56 albertel Exp $
+# $Id: lonplot.pm,v 1.92 2003/10/24 17:35:32 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -115,7 +115,7 @@
 ###################################################################
 my @gnuplot_edit_order = 
     qw/alttag bgcolor fgcolor height width font transparent grid samples 
-    border align texwidth plottype/;
+    border align texwidth texfont plottype/;
 
 my $gnuplot_help_text = <<"ENDPLOTHELP";
 <p>
@@ -232,6 +232,13 @@
          edit_type   => 'entry',
          size        => '5'
          },
+     texfont     => {
+         default     => '22',
+         test        => $int_test,
+         description => 'Font size to use in TeX output (pts):',
+         edit_type   => 'choice',
+         choices     => [qw/10 12 14 16 18 20 22 24 26 28 30 32 34 36/],
+         },
      plottype  => {
 	 default     => 'Cartesian',
 	 test        => sub {$_[0]=~/^(Polar|Cartesian)$/},
@@ -987,7 +994,7 @@
 sub get_attributes{
     my ($values,$defaults,$parstack,$safeeval,$tag) = @_;
     foreach my $attr (keys(%{$defaults})) {
-	if ($attr eq 'texwidth') {
+	if ($attr eq 'texwidth' || $attr eq 'texfont') {
 	    $values->{$attr} = 
 		&Apache::lonxml::get_param($attr,$parstack,$safeeval,undef,1);
 	} else {
@@ -1014,6 +1021,7 @@
     my ($tmpdir,$filename,$target)= @_;
     my $gnuplot_input = '';
     my $curve;
+    my $pt = $plot{'texfont'};
     # Collect all the colors
     my @Colors;
     push @Colors, $plot{'bgcolor'};
@@ -1034,7 +1042,7 @@
 	# set output
 	$gnuplot_input .= "set output\n";
     } elsif ($target eq 'tex') {
-	$gnuplot_input .= "set term postscript eps monochrome solid \"Helvetica\" 25 \n";
+	$gnuplot_input .= "set term postscript eps monochrome solid \"Helvetica\" $pt \n";
 	$gnuplot_input .= "set output \"/home/httpd/perl/tmp/".
 	    &Apache::lonnet::unescape($filename).".eps\"\n";
     }
@@ -1055,9 +1063,9 @@
     # title, xlabel, ylabel
     # titles
     if ($target eq 'tex') {
-        $gnuplot_input .= "set title  \"$title\" font \"Helvetica,25pt\"\n"  if (defined($title)) ;
-        $gnuplot_input .= "set xlabel \"$xlabel\" font \"Helvetica,25pt\" \n" if (defined($xlabel));
-        $gnuplot_input .= "set ylabel \"$ylabel\" font \"Helvetica,25pt\"\n" if (defined($ylabel));
+        $gnuplot_input .= "set title  \"$title\" font \"Helvetica,".$pt."pt\"\n"  if (defined($title)) ;
+        $gnuplot_input .= "set xlabel \"$xlabel\" font \"Helvetica,".$pt."pt\" \n" if (defined($xlabel));
+        $gnuplot_input .= "set ylabel \"$ylabel\" font \"Helvetica,".$pt."pt\"\n" if (defined($ylabel));
     } else {
         $gnuplot_input .= "set title  \"$title\"  \n"  if (defined($title)) ;
         $gnuplot_input .= "set xlabel \"$xlabel\" \n" if (defined($xlabel));
@@ -1103,7 +1111,7 @@
     my $label;
     foreach $label (@labels) {
 	$gnuplot_input .= 'set label "'.$label->{'text'}.'" at '.
-	    $label->{'xpos'}.','.$label->{'ypos'}.' '.$label->{'justify'}.' font "Helvetica,25pt"'.$/ ;
+	    $label->{'xpos'}.','.$label->{'ypos'}.' '.$label->{'justify'}.' font "Helvetica,'.$pt.'pt"'.$/ ;
     }
     if ($target eq 'tex') {
         $gnuplot_input .="set size 1,".$plot{'height'}/$plot{'width'}*1.38;