[GRASSLIST:9859] Re: Learning to use freetype fonts

David Finlayson david.p.finlayson at gmail.com
Mon Jan 16 12:29:41 EST 2006


On 1/15/06, Hamish <hamish_nospam at yahoo.com> wrote:

>
> > That is, without d.font.freetype, I can't get legend text, etc...
>
> this doesn't work?
>
> G> d.font.freetype font=""   # turns off freetype support
> G> d.font font=romans
> G> echo "`g.version`" | d.text
>

Yes the old vector fonts work. However, my problem is the opposite. I
can't get any FreeType text to show up using:

> d.font.freetype font=/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
> d.legend <raster>

I see the color patches, but no text.

Likewise:

> d.font.freetype font=/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
> echo "`g.version`" | d.text

produces nothing on the screen.

However, d.text.freetype works as advertised and I see a freetype font
on the monitor. Thanks to your explanation, I now know that this is
using different code.

Is it enough to add the following during ./configure to get freetype
support for normal text operations?

--with-freetype \
--with-freetype-includes=/usr/include/freetype2 \

On 1/15/06, Hamish <hamish_nospam at yahoo.com> wrote:
> > > I recently compiled GRASS with freetype support and I am trying to
> > > learn to use it. When I follow the following sequence to define a
> > > default font, it fails:
> > >
> > > GRASS 6.1.cvs (WASPN_NAD83):~ > locate bitstream | grep 'Vera'
> ..
> > > /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
> ..
> > > GRASS 6.1.cvs (WASPN_NAD83):~ > d.font.freetype \
> > >   font=/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
> ..
> > > GRASS 6.1.cvs (WASPN_NAD83):~ > d.text.freetype -n text="Hello"
> > > east=20,20 ERROR: No font selected
> > >
> > > But, if I call the font directly in the command it works:
> > >
> > > GRASS 6.1.cvs (WASPN_NAD83):~ > d.text.freetype -n text="Hello" \
> > >   east=20,20
> > >   path=/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
> > >
> > > (successfully draws on the monitor)
> > >
> > > Without d.text.freetype working, I can't see text in legends or map
> > > titles. What's the secret to getting this working?
>
>
> Some history:
>
> First there were GRASS fonts* which you selected with d.font. These
> fonts were used by d.text, d.legend, d.vect, d.labels, d.barscale,
> d.graph, etc.
>
> [*] cyrilc,gothgbt,gothgrt,gothitt,greekc,greekcs,greekp,
>     greeks,italicc,italiccs,italict,romanc,romancs,romand,
>     romans,romant,scriptc,scripts
>
> Maybe if you were Greek you could make use of these for some text, but
> for non-english it wasn't very good. And for english results could be
> ugly. Many people used a graphics program to add text to exported
> maps instead of using the build in fonts.
>
> So Huidae Cho wrote d.text.freetype to draw text to the screen using
> a local FreeType (or TrueType) font. This was great for everyone, but
> wasn't a general & automatic solution for the above modules.
>
> Time passed & the i18n of GRASS came to be. The FOSS4G team (AFAIK)
> created the infrastructure and the d.font.freetype module so the main
> GRASS font (romans et al) could be over-ridden by d.font.freetype and
> so d.vect, d.legend, etc could now use FreeType fonts as the default.
>
> Thus the d.text.freetype module is independent of the d.font.freetype
> module, but the d.text module does observe the d.font.freetype setting.
>
> In hind-sight this is pretty confusing, & I apologise if the help pages
> do not make this clear. Please point out where improvements could be made.
>
> Perhaps d.text.freetype could "pick" the font set by d.font.freetype
> from the GRASS display driver if the font isn't explicitly given, instead
> of an error somehow. Not sure how to extract that from the driver, maybe
> d.font.freetype needs to set/update a new g.gisenv variable?
>
> ps.map is another (confusing) story....
>
>
> > That is, without d.font.freetype, I can't get legend text, etc...
>
> this doesn't work?
>
> G> d.font.freetype font=""   # turns off freetype support
> G> d.font font=romans
> G> echo "`g.version`" | d.text
>
>
> Also, I have this in my ~/.grass.bashrc file:
> alias d.font.vera='d.font.freetype /usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf'
>
> which I find useful.
>
>
> Hamish
>


--
David Finlayson
Marine Geology & Geophysics
School of Oceanography
Box 357940
University of Washington
Seattle, WA  98195-7940
USA

Office: Marine Sciences Building, Room 112
Phone: (206) 616-9407
Web: http://students.washington.edu/dfinlays




More information about the grass-user mailing list