I am trying to rasterize a rectangle which is centered around y==0.

I get a bitmap half as high as I expect. 

More complicated tests suggest that everything below y==0 is clipped.

Test file included.

(Note: I do not have a Face open. I'm going directly from an FT_Outline
to an FT_Bitmap).
#include <string.h>
#include <stdlib.h>
#include <math.h>

#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_OUTLINE_H

static FT_Library context;

int main(int argc, char **argv) {
    FT_Outline outline;
    FT_Bitmap bitmap;
    char tags[4];
    short contours[1];
    FT_Vector points[4];
    int k,j,rowcnt,err;

    if ( FT_Init_FreeType( &context )) {
	fprintf( stderr, "Init failed.\n" );
return( 2 );
    }

    memset(&outline,0,sizeof(outline));

    outline.n_contours = 1;
    outline.tags = tags;
    outline.contours = contours;
    outline.n_points = 4;
    outline.points = points;
    outline.flags = FT_OUTLINE_NONE;

    points[0].x = 73 ; points[0].y =  899;
    points[1].x = 427; points[1].y =  899;
    points[2].x = 427; points[2].y = -899;
    points[3].x = 73 ; points[3].y = -899;
    contours[0] = 3;

    tags[0] = tags[1] = tags[2] = tags[4] = 0x1;	/* On-curve */


    memset(&bitmap,0,sizeof(bitmap));
    bitmap.rows = (((int) (ceil(899.0/(1<<6))-floor(-899.0/(1<<6))))) +1;
    bitmap.width = (((int) (ceil(427./(1<<6))-floor(  73.0/(1<<6))))) +1;
    bitmap.pitch = (bitmap.width+7)>>3;
    bitmap.num_grays = 0;
    bitmap.pixel_mode = ft_pixel_mode_mono;
    bitmap.buffer = calloc(bitmap.pitch*bitmap.rows,sizeof(char));
    
    err = (FT_Outline_Get_Bitmap)(context,&outline,&bitmap);
    if ( err ) {
	fprintf( stderr, "Rasterize failed. %d\n", err );
return( 2 );
    }

    rowcnt = 0;
    for ( k=0; k<bitmap.rows; ++k ) {
	for ( j=bitmap.pitch-1; j>=0 && bitmap.buffer[k*bitmap.pitch+j]==0; --j );
	if ( j!=-1 )
	    ++rowcnt;
    }

    fprintf( stderr, "I expect to have a bitmap with about %d rows. Instead I get one with %d rows\n",
	bitmap.rows-1, rowcnt );
    fprintf( stderr, " It looks as though the bitmap is clipped at y==0\n" );
return( 1 );
}
_______________________________________________
Freetype-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/freetype-devel

Reply via email to