[GRASS-dev] How to change fonts in gis manager?

Glynn Clements glynn at gclements.plus.com
Mon Nov 6 09:40:34 EST 2006

Michael Barton wrote:

> I¹ve created a nice TclTk panel for d.text.new in the GIS Manager. It works
> fine. Now I¹d like to be able to change the fonts it uses. Currently, it
> only seems to use romans.
> I¹ve taken out the hard coded d.font romans from the gis.m display routine
> as it seems to be no longer needed with the new drivers.
> But still, when I run d.font (which requires an x.mon to run) and
> d.font.freetype, it has no effects on d.text.new. I want to embed font
> selection in the d.text.new panel but want to make sure it works and see
> what format of fonts definitions it will accept.
> Do you have any idea why changing the fonts doesn¹t have any effects on
> d.text.new?

d.font and d.font.freetype don't work with direct rendering, as there
is no monitor process to retain state between d.* commands; each d.*
command runs as if with a freshly-started monitor. Similarly, d.frame
and d.save don't work, for the same reason.

To set the default font for direct rendering, you have to use the
environment variables:


Note that GRASS_FONT accepts either FreeType or stroke fonts, while
GRASS_FT_FONT only accepts FreeType fonts. If both are set,
GRASS_FT_FONT takes precedence over GRASS_FONT. If neither are set,
"romans" is used.

For GRASS_FONT, the value is passed directly to R_font(), and should
be one of:

1. The full path to a stroke font, beginning with $GISBASE/fonts.
2. The full path to a FreeType font (.ttf file).
3. The name of a FreeType font from the freetypecap file.
4. The name of a stroke font in the $GISBASE/fonts directory.

If the value begins with a "/", it's a full path. If it begins with
(the expansion of) $GISBASE/fonts, it's assumed to be a stroke font,
otherwise a freetype font.

If the value doesn't begin with a "/", it's first searched for in the
freetypecap file; if it isn't found, it's assumed to be the name of a
stroke font.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-dev mailing list