[GRASS-dev] thinking about font variables

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.

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

Michael Barton 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.

Hamish

AFAIK Bitstream Vera are free fonts, so we could bundle them in GRASS
in a predictable location as a fallback TT fontset.

Daniel.

On 4/25/07, Hamish <hamish_nospam@yahoo.com> wrote:

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.

Hamish

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

--
-- Daniel Calvelo Aros

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

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

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

Michael Barton wrote:

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

Note that either a font name (from freetypecap) or a complete path can
be used for GRASS_FONT (essentially, R_font() accepts either form, and
thus so does anything which sets a font). You can use "d.font -l" to
get a list of valid names (both stroke and FreeType fonts).

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.

You can set GRASS_FONT (etc) in e.g. ~/.grass.bashrc. mon.select uses
those variables when selecting a monitor, and direct rendering also
uses them.

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

I'm not convinced that a GRASS variable is a good idea here. At a
minimum, the environment variables would have to take precedence (for
the GUI, and so that the setting can be overriden on a per-command
basis).

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.

Again, this would probably want to be a fallback, with the freetypecap
file being used first. Also, it would really need to be a path rather
than a single directory.

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

On 4/26/07 1:27 AM, "Glynn Clements" <glynn@gclements.plus.com> wrote:

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.

You can set GRASS_FONT (etc) in e.g. ~/.grass.bashrc. mon.select uses
those variables when selecting a monitor, and direct rendering also
uses them.

I didn't know this. If a default can be set in .grass.bashrc, then it
doesn't need to be set elsewhere. I'll try this out.

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.

Again, this would probably want to be a fallback, with the freetypecap
file being used first. Also, it would really need to be a path rather
than a single directory.

A full path is what I meant.

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

I've had good success with this method for some time now. I use arial for all of my text layers. From my .bashrc:

export GRASS_FT_FONT=/home/epatton/Fonts/arialbd.ttf
export GRASS_FONT=/home/epatton/Fonts/arialbd.ttf

~ Eric.

-----Original Message-----
From: grass-dev-bounces@grass.itc.it on behalf of Michael Barton
Sent: Thu 4/26/2007 10:09 AM
To: Glynn Clements
Cc: Hamish; grass-dev@grass.itc.it
Subject: Re: [GRASS-dev] thinking about font variables

On 4/26/07 1:27 AM, "Glynn Clements" <glynn@gclements.plus.com> wrote:

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.

You can set GRASS_FONT (etc) in e.g. ~/.grass.bashrc. mon.select uses
those variables when selecting a monitor, and direct rendering also
uses them.

I didn't know this. If a default can be set in .grass.bashrc, then it
doesn't need to be set elsewhere. I'll try this out.

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.

Again, this would probably want to be a fallback, with the freetypecap
file being used first. Also, it would really need to be a path rather
than a single directory.

A full path is what I meant.

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

_______________________________________________
grass-dev mailing list
grass-dev@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass-dev

I've been at meetings and haven't had a chance to try this on my Mac. Is
there a way for this to work for Windows folks?

Michael

On 4/26/07 10:03 AM, "Patton, Eric" <epatton@nrcan.gc.ca> wrote:

I've had good success with this method for some time now. I use arial for all
of my text layers. From my .bashrc:

export GRASS_FT_FONT=/home/epatton/Fonts/arialbd.ttf
export GRASS_FONT=/home/epatton/Fonts/arialbd.ttf

~ Eric.

__________________________________________
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

Michael Barton wrote:

> I've had good success with this method for some time now. I use arial for all
> of my text layers. From my .bashrc:
>
> export GRASS_FT_FONT=/home/epatton/Fonts/arialbd.ttf
> export GRASS_FONT=/home/epatton/Fonts/arialbd.ttf

I've been at meetings and haven't had a chance to try this on my Mac. Is
there a way for this to work for Windows folks?

The same general concept should work on Windows, except that setting
environment variables is typically different. AFAICT, init.bat doesn't
implement an equivalent of ~/.grass.bashrc, although that wouldn't be
hard to add. Alternatively, you could start grass via a batch file
which set those variables first.

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

On 27/04/07 08:46, Glynn Clements wrote:

Michael Barton wrote:

I've had good success with this method for some time now. I use arial for all
of my text layers. From my .bashrc:

export GRASS_FT_FONT=/home/epatton/Fonts/arialbd.ttf
export GRASS_FONT=/home/epatton/Fonts/arialbd.ttf

I've been at meetings and haven't had a chance to try this on my Mac. Is
there a way for this to work for Windows folks?

The same general concept should work on Windows, except that setting
environment variables is typically different. AFAICT, init.bat doesn't
implement an equivalent of ~/.grass.bashrc, although that wouldn't be
hard to add. Alternatively, you could start grass via a batch file
which set those variables first.

In the native windows version GRASS _is_ started via a batch file (grass63.bat) which currently contains:

set WINGISBASE=\home\mlennert\SRC\GRASS\grass6\dist.i486-pc-linux-gnu
"%WINGISBASE%\etc\init.bat" %*

Moritz

Moritz Lennert wrote:

>>> I've had good success with this method for some time now. I use arial for all
>>> of my text layers. From my .bashrc:
>>>
>>> export GRASS_FT_FONT=/home/epatton/Fonts/arialbd.ttf
>>> export GRASS_FONT=/home/epatton/Fonts/arialbd.ttf
>> I've been at meetings and haven't had a chance to try this on my Mac. Is
>> there a way for this to work for Windows folks?
>
> The same general concept should work on Windows, except that setting
> environment variables is typically different. AFAICT, init.bat doesn't
> implement an equivalent of ~/.grass.bashrc, although that wouldn't be
> hard to add. Alternatively, you could start grass via a batch file
> which set those variables first.

In the native windows version GRASS _is_ started via a batch file
(grass63.bat) which currently contains:

set WINGISBASE=\home\mlennert\SRC\GRASS\grass6\dist.i486-pc-linux-gnu
"%WINGISBASE%\etc\init.bat" %*

Modifying the installed grass63.bat or init.bat scripts is undesirable
if you have more than one user (although that's less likely in a
Windows environment).

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

On my Mac works.
export GRASS_FONT=/Users/adiez/Library/Fonts/Arial
export GRASS_FT_FONT=/Users/adiez/Library/Fonts/Mistral
The “export” can be done from the grass terminal before gis.m &, so if you don’t like your results you can exit the gis manager, change the fonts and launch gis.m again.
Agustin

On Apr 27, 2007, at 6:43 AM, Michael Barton wrote:

I’ve been at meetings and haven’t had a chance to try this on my Mac. Is

there a way for this to work for Windows folks?

Michael

On 4/26/07 10:03 AM, “Patton, Eric” <epatton@nrcan.gc.ca> wrote:

I’ve had good success with this method for some time now. I use arial for all

of my text layers. From my .bashrc:

export GRASS_FT_FONT=/home/epatton/Fonts/arialbd.ttf

export GRASS_FONT=/home/epatton/Fonts/arialbd.ttf

~ Eric.