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

albertel lon-capa-cvs-allow@mail.lon-capa.org
Fri, 03 Aug 2007 06:08:07 -0000


albertel		Fri Aug  3 02:08:07 2007 EDT

  Modified files:              
    /loncom/xml	lonplot.pm 
  Log:
  - eliminate $pt have get_font return the correct size info for the selected target
  
  
Index: loncom/xml/lonplot.pm
diff -u loncom/xml/lonplot.pm:1.123 loncom/xml/lonplot.pm:1.124
--- loncom/xml/lonplot.pm:1.123	Fri Aug  3 02:00:18 2007
+++ loncom/xml/lonplot.pm	Fri Aug  3 02:08:06 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Dynamic plot
 #
-# $Id: lonplot.pm,v 1.123 2007/08/03 06:00:18 albertel Exp $
+# $Id: lonplot.pm,v 1.124 2007/08/03 06:08:06 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -703,6 +703,7 @@
      );
 
 sub get_font {
+    my ($target) = @_;
     my ($size, $selected_font);
 
     if ( $Apache::lonplot::plot{'font'} =~ /^(small|medium|large)/) {
@@ -720,6 +721,9 @@
 	$size = $Apache::lonplot::plot{'font'};
 	$selected_font = $font_properties{$Apache::lonplot::plot{'fontface'}};
     }
+    if ($target eq 'tex' && defined($Apache::lonplot::plot{'texfont'})) {
+	$size = $Apache::lonplot::plot{'texfont'};
+    }
     return ($size, $selected_font);
 }
 
@@ -1117,10 +1121,9 @@
 ##------------------------------------------------------- write_gnuplot_file
 sub write_gnuplot_file {
     my ($tmpdir,$filename,$target)= @_;
-    my ($fontsize, $font_properties) =  &get_font();
+    my ($fontsize, $font_properties) =  &get_font($target);
     my $gnuplot_input = '';
     my $curve;
-    my $pt = $Apache::lonplot::plot{'texfont'};
     #
     # Check to be sure we do not have any empty curves
     my @curvescopy;
@@ -1234,9 +1237,9 @@
     # title, xlabel, ylabel
     # titles
     if ($target eq 'tex') {
-	$gnuplot_input .= "set title  \"$title\"  font \"".$font_properties->{'printname'}.",".$pt."pt\"\n" if (defined($title)) ;
-	$gnuplot_input .= "set xlabel \"$xlabel\" font \"".$font_properties->{'printname'}.",".$pt."pt\"\n" if (defined($xlabel));
-	$gnuplot_input .= "set ylabel \"$ylabel\" font \"".$font_properties->{'printname'}.",".$pt."pt\"\n" if (defined($ylabel));
+	$gnuplot_input .= "set title  \"$title\"  font \"".$font_properties->{'printname'}.",".$fontsize."pt\"\n" if (defined($title)) ;
+	$gnuplot_input .= "set xlabel \"$xlabel\" font \"".$font_properties->{'printname'}.",".$fontsize."pt\"\n" if (defined($xlabel));
+	$gnuplot_input .= "set ylabel \"$ylabel\" font \"".$font_properties->{'printname'}.",".$fontsize."pt\"\n" if (defined($ylabel));
     } else {
         $gnuplot_input .= "set title  \"$title\"  \n" if (defined($title)) ;
         $gnuplot_input .= "set xlabel \"$xlabel\" \n" if (defined($xlabel));
@@ -1284,7 +1287,7 @@
 	$gnuplot_input .= 'set label "'.$label->{'text'}.'" at '.
 	    $label->{'xpos'}.','.$label->{'ypos'}.' '.$label->{'justify'};
         if ($target eq 'tex') {
-	    $gnuplot_input .=' font "'.$font_properties->{'printname'}.','.$pt.'pt"' ;
+	    $gnuplot_input .=' font "'.$font_properties->{'printname'}.','.$fontsize.'pt"' ;
         }
         $gnuplot_input .= $/;
     }