[GRASS5] [bug #2129] (grass) d.text.freetype: bad rendering

Glynn Clements glynn.clements at virgin.net
Wed Sep 24 18:36:24 EDT 2003


Request Tracker wrote:

> I can't find any documentation for src/libes/raster/Raster.c
> R_raster_char() or really know how to pull apart draw_character() much
> more.

R_raster_char() simply sends its arguments to the driver, preceded by
the RASTER_CHAR opcode; the actual work is done by the driver.

However, the net effect is to perform a raster drawing operation.

int R_raster_char(int num, int nrows, int withzero, unsigned char *ras);

"num" is the number of columns.

"nrows" is the number of rows to be drawn, all of which are identical
(this is used for vertical scaling).

"withzero" should be true (non-zero) if zero pixels are to be drawn in
colour zero, false (zero) if they are to be transparent (i.e. not
drawn).

"ras" should point to "num" bytes of data, which constitute the pixels
for a single row of a raster image.

The result is that a rectangular area of width "num" and height
"nrows", with its top-left corner at the current position, is filled
with "nrows" copies of the data pointed to by "ras".

Example: if you wanted to draw a byte-per-pixel image, you would use:

	unsigned char image[HEIGHT][WIDTH];

	for (y = 0; y < HEIGHT; y++)
	{
		R_move_abs(x_left, y_top + y);
		R_raster_char(WIDTH, 1, 1, image[y]);
	}

Looking at the d.text.freetype source code, it appears to be guessing
the pitch[1] of the rendered bitmap from the width, rather than
reading it from the FT_Bitmap structure. That would certainly explain
your symptoms, although there may be other problems.

[1] The number of bytes between the start of one row and the next.

Basically, draw_character() uses FT_Render_Glyph() to render the glyph
as a bitmap (1-bit-per-pixel); it then expands the image to
1-byte-per-pixel, and uses R_raster_char() to draw it.

The most likely mode of failure is that the conversion is wrong,
probably because it's making certain assumptions about the layout of
the bitmap data which turn out to be incorrect (at least, for you; the
minimal testing which I did worked, and presumably the same applies to
Huidae).

Actually fixing this will require reading the FreeType documentation
rather than trial-and-error.

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-dev mailing list