[GRASS-dev] how to set fonts for d.text.new

Glynn Clements glynn at gclements.plus.com
Thu Sep 21 12:38:32 EDT 2006


Huidae Cho wrote:

> >    I$(C!/(Bd like to put d.text.new into the GUI layer toolbar, since it now combines GRASS and freetype fonts, and works on all platforms as far as I can tell.
> >    To make life easier for users, my plan is to allow them to also set the font in the same options panel. Give the discussions of a few weeks back that I sort of followed, this leaves me with several questions about how to do this in an easy, useful way, that doesn$(C!/(Bt mess up other things.
> >    Currently, d.font and d.font.freetype offer a non-interactive entry widget for typing in a font name and path. TclTk offers a built-in font selection dialog that I$(C!/(Bve used in some other modules (thematic mapping legends, PS text) that lets a users interactively select system fonts. Will these work with d.text.new? I$(C!/(Bll also leave it so that a user can type in something if they want.
> 
> If the system font is a FreeType font, you can pass the path to d.font
> so that d.text.new can pick it up later for drawing.  However, for
> immediate rendering currently used by gis.m, you may need to set
> GRASS_FT_FONT, GRASS_FT_ENCODING, GRASS_FONT environment variables
> since, AFAIK, d.font(.freetype) has nothing to do with immediate
> rendering (they don't set font related env vars).
> 
> > Which is better to use for setting fonts in this way: d.font or f.font.freetype?
> 
> d.font has been already merged with d.font.freetype, so TclTk code for
> d.font should work with this new implementation. But again, it works
> only for monitors.
> 
> > What will happen in the GUI is that d.font.freetype (or d.font)
> > will run, followed by d.text.new. Will this affect the fonts in all
> > subsequent layers (e.g., for legends)? If so, how can I put the font
> > back to the way it was before running the font/text layer?
> 
> Save the above environment variables, display text, and restore previous
> font settings?

If you're using immediate rendering, you need to use the environment
variables mentioned above. This will affect the default font in all
modules.

I suggest providing a global setting for these variables, as well as
allowing it to be overriden on a per-command basis.

Since R_font() was extended to support both stroke and FreeType fonts,
GRASS_FT_FONT is essentially redundant; you can use GRASS_FONT for
either. The value of $GRASS_FONT can either be the full path to a
(stroke or FreeType) font file, or the name of any FreeType font in
the $GISBASE/etc/freetypecap file, or the name of any stroke font in
$GISBASE/fonts.

With immediate rendering, the driver's state is completely reset at
the beginning of each d.* command, so state-setting commands (e.g. 
d.font, d.frame) are meaningless when using immediate rendering.

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list