[GRASS-dev] Re: [bug #4905] (grass) gis.m: d.text.freetype does not allow spaces in text

Glynn Clements glynn at gclements.plus.com
Wed Aug 30 09:28:53 EDT 2006


Michael Barton wrote:

> As I understand it, d.font.freetype + d.text works; d.text.freetype does
> not.

The former uses ft_render_mode_normal, the latter ft_render_mode_mono.

Is there anything (useful) which the latter does but the former
doesn't? Or can we kill d.text.freetype?

Hmm. Immediate rendering doesn't work with FreeType fonts at present. 
You can't use d.font/d.font.freetype as each d.* command is self
contained. The default font for immediate rendering is set with
GRASS_FONT, but that currently only supports the stroke fonts. I'll
fix this today.

Using the driver's built-in FreeType handling has the advantage that
we can implement anti-aliased text when using the PNG driver
(including immediate rendering) in true-colour mode.

The FreeType text rendering uses the driver's draw_bitmap operation,
which isn't directly exposed (i.e. there is no R_draw_bitmap() or
similar). d.text.freetype uses R_raster_char().

The draw_bitmap operation could easily be extended to support
anti-aliasing. Currently, the bitmap is one byte per pixel, with zero
indicating transparent and non-zero indicating opaque. Changing it to
an alpha channel would involve removing the "... > 128 ? 1:0" from
lib/driver/text3.c:272 and having the driver's draw_bitmap operation
either perform the check itself (for XDRIVER or for the PNG driver
using indexed colour) or using anti-aliasing (for the PNG driver using
true colour).

Actually, we could just make the draw_bitmap operation available
through an R_draw_bitmap() function for d.text.freetype to use.

Finally, there should probably be an option to select the rendering
mode (ft_render_mode_{normal,mono}); if you aren't using
anti-aliasing, ft_render_mode_mono will typically produce better
results (assuming that ft_render_mode_mono actually works).

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




More information about the grass-dev mailing list