[GRASS-dev] d.font: font name checking?

Glynn Clements glynn at gclements.plus.com
Fri May 23 05:07:25 EDT 2008


Markus Neteler wrote:

> I see that d.font doesn't do any validation of the font name:
> 
> GRASS 6.4.svn (eth_utm32):~ > d.font romans
> GRASS 6.4.svn (eth_utm32):~ > d.font paul
> GRASS 6.4.svn (eth_utm32):~ > d.font glynn
> GRASS 6.4.svn (eth_utm32):~ >
> 
> Is there a way to add that?

The code to read the font list is already there for the -l/-L
switches, so you can just read the list and check that the font is in
that list. However, note that the argument to font= can also be an
absolute path to a .ttf file, which needn't exist in the fontcap file.

This issue affects any module which accepts font names, e.g. d.text.

At present, R_font() doesn't return a result. R_font() itself doesn't
care whether the font exists; the font isn't actually loaded until you
try to draw something with it.

[Part of the reason for this is so that, when using direct rendering,
modules don't waste time loading the default "romans" font when they
aren't going to use it.]

Similarly, there's no check that $GRASS_FONT is valid; the value is
just passed to R_font(), and validity only becomes an issue when you
try to draw text.

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


More information about the grass-dev mailing list