[GRASS-dev] thinking about font variables

Glynn Clements glynn at gclements.plus.com
Wed Apr 25 19:15:41 EDT 2007

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
> 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.:


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).

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-dev mailing list