On 4/25/07 4:15 PM, "Glynn Clements" <glynn@gclements.plus.com> wrote:
Hamish wrote:
After sleeping on it, I�d like to propose 2 new kinds of font variables for
GRASS.
GRASS_FONTPATH would be an environmental variable like GRASS_PROJSHARE. It
is a convenience to help users get to their fonts easily without a lot of
browsing around. Like GRASS_PROJSHARE, this could be set manually (e.g., in
a user�s .profile) or Init.sh will make some reasonable guesses as to a
logical path on each platform (e.g., /Library/Fonts on a Mac OS X). It could
be used from the command line or in the GUI to get to the font directory for
easy font selection�e.g., the default font path shown in the autogenerated
dialog for d.text could be initially set to $GRASS_FONTPATH.
GRASS_DEFAULTFONT would be a GRASS environmental variable, optionally set in
.grassrc6. It would take any value accepted by d.font. The purpose of this
variable would be to allow for a default font to be set by the user and
persist from session to session. If GRASS_DEFAULTFONT is not set, GRASS
would simply default to it current stroke font setting. Explicitly setting
d.font or specifying a font in something like d.text would temporarily
override GRASS_DEFAULTFONT. I can see how I can use it in the rendering part
of the GUI to use this font for every rendering operation. It would be nice,
however, if this could be used automatically for any display command that
renders fonts (e.g., d.legend).
Implementing this in the GUI is fairly trivial. I don�t know what kind of
work would be needed to make d.* commands automatically respect
GRASS_DEFAULTFONT, however.
FWIW, I simply have this line in my .grass.bashrc file: (GRASS 6.3)
alias d.font.vera='d.font
path=/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf'
or for GRASS 6.2:
alias d.font.vera='d.font.freetype
/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf'
then I run d.font.vera whenever I want that.
If you put e.g.:
vera:/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf:iso-8859-1:
into $GISBASE/etc/freetypecap, you can use "d.font vera" to get the
same result.
At present, the freetypecap file is copied from scripts/d.text.freetype.
We can probably improve upon that, e.g. looking for .ttf files in
likely font directories (e.g. /usr/share/fonts, /usr/lib/X11/fonts,
etc; suggestions for additional directories are welcome).
Even if we have an environment variable for a font path, the
freetypecap file has the advantage that you can specify a more useful
name (a lot of TTF files still use DOS 8.3 filenames).
This works if you type d.font vera from the command line and follow it with
a d.* command.
However, it will do nothing if you run d.font vera and then run a d.*
command from the GUI into a TclTk (or wxPython) canvas, because these run in
direct rendering mode. The only way to set fonts there is to set GRASS_FONT
immediately prior to rendering. This can be done with a file browse dialog
to find a font file and set it to a variable that can be used in the
GRASS_FONT= statement.
However, with the d.font from the command line or setting GRASS_FONT from
within the GUI, the setting does not persist beyond the current GRASS
session. That is, unless you want the default (ugly) stroke font, you must
set the font at least for each session and (depending on what you do) for
each command.
My suggestion is to have an optional font setting in the form of a variable
in the .grassrc6 file that would persist past the current session. That is,
to let the user replace the Romans stroke font with something else as the
default GRASS font for every GRASS session unless it is explicitly
overridden (e.g., in a d.text command). From the user standpoint, it would
be great if this could be done by a flag in d.font (like the new flag for
g.region that lets it set a new default WIND).
The other suggestion is for a GRASS_FONTPATH environmental variable that
would let a user substitute $GRASS_FONTPATH/Vera.ttf for typing (or browsing
for) /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf. This is only a
convenience, but a helpful one, along the lines of the GRASS_PROJSHARE
variable.
Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University
phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton