[GRASS-SVN] r58817 - grass/branches/develbranch_6/display/d.legend

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jan 30 19:03:33 PST 2014


Author: hamish
Date: 2014-01-30 19:03:32 -0800 (Thu, 30 Jan 2014)
New Revision: 58817

Modified:
   grass/branches/develbranch_6/display/d.legend/description.html
   grass/branches/develbranch_6/display/d.legend/main.c
Log:
respect the GRASS_FONTSIZE enviro variable if it is set (for G7 we need to revive the disccussion about having all d.* modules respect the enviro vars, removing the smattering of font module options, and having the module guis act as wrapper scripts offering the font name, charset, size, ... then setting the environment as needed); remove some old or irrelevant see alsos in the man page

Modified: grass/branches/develbranch_6/display/d.legend/description.html
===================================================================
--- grass/branches/develbranch_6/display/d.legend/description.html	2014-01-31 00:09:39 UTC (rev 58816)
+++ grass/branches/develbranch_6/display/d.legend/description.html	2014-01-31 03:03:32 UTC (rev 58817)
@@ -88,6 +88,9 @@
 number of categories to scale the legend may no longer produce the desired
 output, although the auto-scaling should still produce something that looks 
 good in this case.
+<p>
+The auto-scaled font size can be manually overridden by setting the
+<tt>GRASS_FONTSIZE</tt> environment variable.
 
 
 <h2>SEE ALSO</h2>
@@ -97,15 +100,11 @@
 <em><a href="d.colortable.html">d.colortable</a></em><br>
 <em><a href="d.erase.html">d.erase</a></em><br>
 <em><a href="d.font.html">d.font</a></em><br>
-<em><a href="d.font.freetype.html">d.font.freetype</a></em><br>
 <em><a href="d.grid.html">d.grid</a></em><br>
 <em><a href="d.rast.html">d.rast</a></em><br>
 <!-- <em><a href="d.rast.labels.html">d.rast.labels</a></em><br> -->
 <em><a href="d.rast.leg.html">d.rast.leg</a></em><br>
-<em><a href="d.text.html">d.text</a></em><br>
-<em><a href="d.text.freetype.html">d.text.freetype</a></em><br>
 <em><a href="d.vect.thematic.html">d.vect.thematic</a></em><br>
-<em><a href="d.what.rast.html">d.what.rast</a></em><br>
 <em><a href="g.gisenv.html">g.gisenv</a></em><br>
 <em><a href="r.reclass.html">r.reclass</a></em><br>
 
@@ -116,4 +115,5 @@
  Otago University, New Zealand
 <br>Additional improvements from various authors
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>

Modified: grass/branches/develbranch_6/display/d.legend/main.c
===================================================================
--- grass/branches/develbranch_6/display/d.legend/main.c	2014-01-31 00:09:39 UTC (rev 58816)
+++ grass/branches/develbranch_6/display/d.legend/main.c	2014-01-31 03:03:32 UTC (rev 58817)
@@ -77,6 +77,8 @@
     double UserRangeMin, UserRangeMax, UserRangeTemp;
     double *catlist, maxCat;
     int catlistCount, use_catlist;
+    int txsiz;
+    const char *fontsize_override;
 
 
     /* Initialize the GIS calls */
@@ -562,7 +564,6 @@
 
     if (do_smooth) {
 	int wleg, lleg, dx, dy;
-	int txsiz;
 	int ppl;
 	int tcell;
 	float ScaleFactor = 1.0;
@@ -670,12 +671,16 @@
 	    /* scale text to fit in window if position not manually set */
 	    /* usually not needed, except when frame is really narrow   */
 	    if (!use_mouse && opt7->answer == NULL) {	/* ie defualt scaling */
-		ScaleFactor = ((r - x1) / ((MaxLabelLen + 1) * txsiz * 0.81));	/* ?? txsiz*.81=actual text width. */
+		/* ?? txsiz*.81=actual text width. */
+		ScaleFactor = ((r - x1) / ((MaxLabelLen + 1) * txsiz * 0.81));
 		if (ScaleFactor < 1.0) {
 		    txsiz = (int)(txsiz * ScaleFactor);
 		}
 	    }
 
+	    if ((fontsize_override = getenv("GRASS_FONTSIZE")))
+		sscanf(fontsize_override, "%d", &txsiz);
+
 	    if (txsiz < 0)
 		txsiz = 0;	/* keep it sane */
 
@@ -734,7 +739,7 @@
     }
     else {			/* non FP, no smoothing */
 
-	int txsiz, true_l, true_r;
+	int true_l, true_r;
 	float ScaleFactor = 1.0;
 
 	/* set legend box bounds */
@@ -766,6 +771,9 @@
 	    }
 	}
 
+	if ((fontsize_override = getenv("GRASS_FONTSIZE")))
+	    sscanf(fontsize_override, "%d", &txsiz);
+
 	if (dots_per_line < txsiz)
 	    txsiz = dots_per_line;
 
@@ -897,13 +905,14 @@
 
 	if (do_cats != cats_num) {
 	    cur_dot_row += dots_per_line;
-	    /*          sprintf(buff, "%d of %d categories\n", (j-1), cats_num) ;   */
 
+	    /* sprintf(buff, "%d of %d categories\n", (j-1), cats_num); */
 	    sprintf(buff, "%d of %d categories\n", k, cats_num);
 
 	    /* shrink text if it will run off the screen */
 	    MaxLabelLen = strlen(buff) + 4;
-	    ScaleFactor = ((true_r - true_l) / (MaxLabelLen * txsiz * 0.81));	/* ?? txsiz*.81=actual text width. */
+	    /* ?? txsiz*.81=actual text width. */
+	    ScaleFactor = ((true_r - true_l) / (MaxLabelLen * txsiz * 0.81));
 	    if (ScaleFactor < 1.0) {
 		txsiz = (int)floor(txsiz * ScaleFactor);
 		R_text_size(txsiz, txsiz);



More information about the grass-commit mailing list