[gf] COnverted file functions to FT stream functions.

* src/gf/gflib.c : Converted all the file functions like getc,
fseek,etc. to FT specific stream functions.
This commit is contained in:
Parth Wazurkar 2018-06-24 19:19:43 +05:30
parent 1338d517c4
commit e7c95039f5
3 changed files with 192 additions and 205 deletions

View File

@ -158,18 +158,18 @@
GF_Face face = (GF_Face)gfface; GF_Face face = (GF_Face)gfface;
FT_Error error; FT_Error error;
FT_Memory memory = FT_FACE_MEMORY( face ); FT_Memory memory = FT_FACE_MEMORY( face );
GF_Glyph go;
face->gf_glyph = &go ;
FT_UNUSED( num_params ); FT_UNUSED( num_params );
FT_UNUSED( params ); FT_UNUSED( params );
FT_TRACE2(( "GF driver\n" )); FT_TRACE2(( "GF driver\n" ));
printf("\nHi I am here\n\n");
/* load font */
error = gf_load_font( stream, face );
if ( !error )
goto Exit;
if ( FT_ERR_EQ( error, Unknown_File_Format ) ) /* load font */
error = gf_load_font( stream, memory, &go );/*printf("face->gf_glyph->code_max %d",go->code_max);printf("Hi I am here1\n");*/
if ( error )
goto Exit; goto Exit;
/* we have a gf font: let's construct the face object */ /* we have a gf font: let's construct the face object */
@ -180,13 +180,13 @@
* an invalid argument error when the font could be * an invalid argument error when the font could be
* opened by the specified driver. * opened by the specified driver.
*/ */
if ( face_index > 0 && ( face_index & 0xFFFF ) > 0 ) /* if ( face_index > 0 && ( face_index & 0xFFFF ) > 0 )
{ {
FT_ERROR(( "GF_Face_Init: invalid face index\n" )); FT_ERROR(( "GF_Face_Init: invalid face index\n" ));
GF_Face_Done( gfface ); GF_Face_Done( gfface );
return FT_THROW( Invalid_Argument ); return FT_THROW( Invalid_Argument );
} }
*/
gfface->num_faces = 1; gfface->num_faces = 1;
gfface->face_index = 0; gfface->face_index = 0;
gfface->face_flags |= FT_FACE_FLAG_FIXED_SIZES | gfface->face_flags |= FT_FACE_FLAG_FIXED_SIZES |
@ -195,13 +195,14 @@
* XXX: TO-DO: gfface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; * XXX: TO-DO: gfface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
* XXX: I have to check for this. * XXX: I have to check for this.
*/ */
/*printf("Hi I am here2\n");*/
gfface->family_name = NULL; gfface->family_name = NULL;
gfface->num_glyphs = (FT_Long)( sizeof(face->gf_glyph->bm_table) ); gfface->num_glyphs = (FT_Long)(go->code_max - go->code_min + 1 );
gfface->num_fixed_sizes = 1; gfface->num_fixed_sizes = 1;
/*printf("Hi I am here3\n");*/
if ( FT_NEW_ARRAY( gfface->available_sizes, 1 ) ) if ( FT_NEW_ARRAY( gfface->available_sizes, 1 ) )
goto Exit; goto Exit;
/*printf("Hi I am here4\n");*/
{ {
FT_Bitmap_Size* bsize = gfface->available_sizes; FT_Bitmap_Size* bsize = gfface->available_sizes;
FT_UShort x_res, y_res; FT_UShort x_res, y_res;
@ -209,14 +210,15 @@
FT_ZERO( bsize ); FT_ZERO( bsize );
bsize->width = (FT_Short) face->gf_glyph->font_bbx_w ; bsize->width = (FT_Short) face->gf_glyph->font_bbx_w ;
bsize->height = (FT_Short) face->gf_glyph->font_bbx_h ; bsize->height = (FT_Short) face->gf_glyph->font_bbx_h ;
bsize->size = face->gf_glyph->font_bbx_xoff ; bsize->size = (FT_Short) face->gf_glyph->ds ; /* Preliminary to be checked for 26.6 fractional points*/
/*x_res = ; /*x_res = ; To be Checked for x_resolution and y_resolution
y_res = ; y_res = ;
*/ */
bsize->y_ppem = face->gf_glyph->font_bbx_yoff ; bsize->y_ppem = face->gf_glyph->font_bbx_yoff ;
bsize->x_ppem = face->gf_glyph->font_bbx_xoff ; bsize->x_ppem = face->gf_glyph->font_bbx_xoff ;
} }
/*printf("Hi I am here5\n");*/
/* Charmaps */ /* Charmaps */
@ -226,7 +228,7 @@
charmap.encoding = FT_ENCODING_NONE; charmap.encoding = FT_ENCODING_NONE;
/* initial platform/encoding should indicate unset status? */ /* initial platform/encoding should indicate unset status? */
charmap.platform_id = TT_PLATFORM_APPLE_UNICODE; charmap.platform_id = TT_PLATFORM_APPLE_UNICODE; /*Preliminary */
charmap.encoding_id = TT_APPLE_ID_DEFAULT; charmap.encoding_id = TT_APPLE_ID_DEFAULT;
charmap.face = face; charmap.face = face;
@ -234,12 +236,14 @@
if ( error ) if ( error )
goto Fail; goto Fail;
/*printf("Hi I am here completed GF_Face_Init1\n");*/
} }
/*printf("Hi I am here6\n");*/
Fail: Fail:
GF_Face_Done( gfface ); GF_Face_Done( gfface );
Exit: Exit:
/* printf("Hi I am here completed GF_Face_Init2 %ld\n",gfface->num_glyphs);*/
return error; return error;
} }
@ -247,16 +251,16 @@
GF_Size_Select( FT_Size size, GF_Size_Select( FT_Size size,
FT_ULong strike_index ) FT_ULong strike_index )
{ {
GF_Face face = (GF_Face)size->face;
FT_UNUSED( strike_index ); FT_UNUSED( strike_index );
FT_Select_Metrics( size->face, 0 ); FT_Select_Metrics( size->face, 0 );
/*
size->metrics.ascender = ; size->metrics.ascender = face->gf_glyph->font_bbx_xoff * 64 ;
size->metrics.descender = ; size->metrics.descender = face->gf_glyph->font_bbx_yoff * 64 ;
size->metrics.max_advance = ; size->metrics.max_advance = face->gf_glyph->font_bbx_w * 64 ;
*/
return FT_Err_Ok; return FT_Err_Ok;
} }
@ -307,10 +311,11 @@
FT_Face face = FT_FACE( gf ); FT_Face face = FT_FACE( gf );
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
FT_Bitmap* bitmap = &slot->bitmap; FT_Bitmap* bitmap = &slot->bitmap;
GF_BitmapRec glyph ; GF_BitmapRec bm ;
FT_UNUSED( load_flags ); FT_UNUSED( load_flags );
printf("Hi I am here in gf_load_glyphs");
if ( !face ) if ( !face )
{ {
@ -326,34 +331,38 @@
FT_TRACE1(( "GF_Glyph_Load: glyph index %d\n", glyph_index )); FT_TRACE1(( "GF_Glyph_Load: glyph index %d\n", glyph_index ));
if ( glyph_index > 0 ) /*if ( glyph_index > 0 )
glyph_index--; /* revert to real index */ glyph_index--;
else else
glyph_index = 0; /* the `.notdef' glyph */ glyph_index = 0;
*/
if ( glyph_index < 0 )
glyph_index = 0;
/* slot, bitmap => freetype, glyph => gflib */ /* slot, bitmap => freetype, glyph => gflib */
glyph = gf->gf_glyph->bm_table[glyph_index]; bm = gf->gf_glyph->bm_table[glyph_index];
/*
bitmap->rows = ; bitmap->rows = bm.mv_y ; /* Prelimiary */
bitmap->width = ; bitmap->width = bm.mv_x ; /* Prelimiary */
bitmap->pitch = ; *//* (In BDF) same as FT_Bitmap.pitch */ /*bitmap->pitch = bm ; *//* Prelimiary */
/* note: we don't allocate a new array to hold the bitmap; */ /* note: we don't allocate a new array to hold the bitmap; */
/* we can simply point to it */ /* we can simply point to it */
ft_glyphslot_set_bitmap( slot, glyph.bitmap ); ft_glyphslot_set_bitmap( slot, bm.bitmap );
slot->format = FT_GLYPH_FORMAT_BITMAP; slot->format = FT_GLYPH_FORMAT_BITMAP;
/*slot->bitmap_left = ; slot->bitmap_left = bm.off_x ; /* Prelimiary */
slot->bitmap_top = ; slot->bitmap_top = bm.off_y ; /* Prelimiary */
slot->metrics.horiAdvance = (FT_Pos) ; slot->metrics.horiAdvance = (FT_Pos) bm.bbx_width - bm.off_x ; /* Prelimiary */
slot->metrics.horiBearingX = (FT_Pos) ; slot->metrics.horiBearingX = (FT_Pos) bm.off_x ; /* Prelimiary */
slot->metrics.horiBearingY = (FT_Pos) ; slot->metrics.horiBearingY = (FT_Pos) bm.off_y ; /* Prelimiary */
slot->metrics.width = (FT_Pos) ; slot->metrics.width = (FT_Pos) ( bitmap->width * 64 ) ; /* Prelimiary */
slot->metrics.height = (FT_Pos) ; slot->metrics.height = (FT_Pos) ( bitmap->rows * 64 ) ; /* Prelimiary */
ft_synthesize_vertical_metrics( &slot->metrics, bm.bbx_height * 64 );
ft_synthesize_vertical_metrics( &slot->metrics, );
*/
Exit: Exit:
return error; return error;
} }

View File

@ -33,7 +33,7 @@ FT_BEGIN_HEADER
FT_UInt bbx_width, bbx_height; FT_UInt bbx_width, bbx_height;
FT_UInt off_x, off_y; FT_UInt off_x, off_y;
FT_UInt mv_x, mv_y; FT_UInt mv_x, mv_y;
unsigned char *bitmap; FT_Byte *bitmap;
FT_UInt raster; FT_UInt raster;
} GF_BitmapRec, *GF_Bitmap; } GF_BitmapRec, *GF_Bitmap;

View File

@ -49,104 +49,87 @@ unsigned char bit_table[] = {
* *
*/ */
long gf_read_intn(FILE*,int); long gf_read_intn(FT_Stream,int);
unsigned long gf_read_uintn(FILE*,int); unsigned long gf_read_uintn(FT_Stream,int);
void gf_skip_n(FILE*,int); void gf_skip_n(FT_Stream,int);
#define READ_INT1(fp) (INT1)gf_read_intn((fp), 1) #define READ_INT1( stream ) (INT1)gf_read_intn(( stream ), 1)
#define READ_UINT1(fp) (UINT1)gf_read_uintn((fp), 1) #define READ_UINT1( stream ) (UINT1)gf_read_uintn(( stream ), 1)
#define READ_INT2(fp) (INT2)gf_read_intn((fp), 2) #define READ_INT2( stream ) (INT2)gf_read_intn(( stream ), 2)
#define READ_UINT2(fp) (UINT2)gf_read_uintn((fp), 2) #define READ_UINT2( stream ) (UINT2)gf_read_uintn(( stream ), 2)
#define READ_INT3(fp) (INT3)gf_read_intn((fp), 3) #define READ_INT3( stream ) (INT3)gf_read_intn(( stream ), 3)
#define READ_UINT3(fp) (UINT3)gf_read_uintn((fp), 3) #define READ_UINT3( stream ) (UINT3)gf_read_uintn(( stream ), 3)
#define READ_INT4(fp) (INT4)gf_read_intn((fp), 4) #define READ_INT4( stream ) (INT4)gf_read_intn(( stream ), 4)
#define READ_UINT4(fp) (UINT4)gf_read_uintn((fp), 4) #define READ_UINT4( stream ) (UINT4)gf_read_uintn(( stream ), 4)
#define READ_INTN(fp,n) (INT4)gf_read_intn((fp), (n)) #define READ_INTN( stream ,n) (INT4)gf_read_intn(( stream ), (n))
#define READ_UINTN(fp,n) (UINT4)gf_read_uintn((fp), (n)) #define READ_UINTN( stream ,n) (UINT4)gf_read_uintn(( stream ), (n))
#define SKIP_N(fp,k) gf_skip_n((fp), (k)) #define SKIP_N( stream ,k) gf_skip_n(( stream ), (k))
/* /*
* Reading a Number from file * Reading a Number from stream
*/ */
unsigned long unsigned long
gf_read_uintn(FILE* fp, int size) gf_read_uintn(FT_Stream stream, int size)
{ {
unsigned long v; unsigned long v;
FT_Error error = FT_Err_Ok;
v = 0L; v = 0L;
while (size >= 1) while (size >= 1)
{ {
v = v*256L + (unsigned long)getc(fp); v = v*256L + (unsigned long)FT_Stream_ReadULong(stream, &error);
stream->pos-=3;
--size; --size;
} }
return v; return v;
} }
/* Preliminary */
unsigned long
gf_read_uint4(FT_Stream stream, int size)
{
unsigned long v;
FT_Error error = FT_Err_Ok;
v = 0L;
while (size >= 1)
{
v = v*256L + (unsigned long)FT_Stream_ReadULong(stream, &error);
--size;
}
return v;
}
long long
gf_read_intn(FILE* fp, int size) gf_read_intn(FT_Stream stream, int size)
{ {
long v; long v;
FT_Error error = FT_Err_Ok;
v = (long)getc(fp) & 0xffL; v = (long)FT_Stream_ReadULong(stream, &error) & 0xffL;
if (v & 0x80L) if (v & 0x80L)
v = v - 256L; v = v - 256L;
--size; --size;
while (size >= 1) while (size >= 1)
{ {
v = v*256L + (unsigned long)getc(fp); v = v*256L + (unsigned long)FT_Stream_ReadULong(stream, &error);
--size; --size;
} }
return v; return v;
} }
void void
gf_skip_n(FILE* fp, int size) gf_skip_n(FT_Stream stream, int size)
{ {
FT_Stream_Skip(stream, (FT_Long)size );
#if 0
while (size > 0) while (size > 0)
{ {
(void)getc(fp); (void)getc(fp);
--size; --size;
} }
#endif
} }
unsigned long
gf_get_uintn(unsigned char *p, int size)
{
unsigned long v;
v = 0L;
while (size >= 1)
{
v = v*256L + (unsigned long) *(p++);
--size;
}
return v;
}
long
gf_get_intn(unsigned char *p, int size)
{
long v;
v = (long)*(p++) & 0xffL;
if (v & 0x80L)
v = v - 256L;
--size;
while (size >= 1)
{
v = v*256L + (unsigned long) *(p++);
--size;
}
return v;
}
/************************************************************************** /**************************************************************************
* *
* API. * API.
@ -154,7 +137,7 @@ unsigned char bit_table[] = {
*/ */
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
gf_read_glyph(FT_FILE* fp, GF_Bitmap bm) gf_read_glyph(FT_Stream stream, GF_Bitmap bm)
{ {
long m, n; long m, n;
int paint_sw; int paint_sw;
@ -165,22 +148,22 @@ unsigned char bit_table[] = {
unsigned char *ptr; unsigned char *ptr;
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
switch (READ_UINT1(fp)) switch (READ_UINT1( stream ))
{ {
case GF_BOC: case GF_BOC:
SKIP_N(fp, 4); SKIP_N( stream , 4);
SKIP_N(fp, 4); SKIP_N( stream , 4);
min_m = READ_INT4(fp); min_m = READ_INT4( stream );
max_m = READ_INT4(fp); max_m = READ_INT4( stream );
min_n = READ_INT4(fp); min_n = READ_INT4( stream );
max_n = READ_INT4(fp); max_n = READ_INT4( stream );
break; break;
case GF_BOC1: case GF_BOC1:
SKIP_N(fp, 1); SKIP_N( stream , 1);
del_m = (INT4)READ_UINT1(fp); del_m = (INT4)READ_UINT1( stream );
max_m = (INT4)READ_UINT1(fp); max_m = (INT4)READ_UINT1( stream );
del_n = (INT4)READ_UINT1(fp); del_n = (INT4)READ_UINT1( stream );
max_n = (INT4)READ_UINT1(fp); max_n = (INT4)READ_UINT1( stream );
min_m = max_m - del_m; min_m = max_m - del_m;
min_n = max_n - del_n; min_n = max_n - del_n;
break; break;
@ -216,7 +199,7 @@ unsigned char bit_table[] = {
m = min_m; m = min_m;
n = max_n; n = max_n;
paint_sw = 0; paint_sw = 0;
while ((instr = (int)READ_UINT1(fp)) != GF_EOC) while ((instr = (int)READ_UINT1( stream )) != GF_EOC)
{ {
if (instr == GF_PAINT_0) if (instr == GF_PAINT_0)
{ {
@ -240,7 +223,7 @@ unsigned char bit_table[] = {
case GF_PAINT1: case GF_PAINT1:
case GF_PAINT2: case GF_PAINT2:
case GF_PAINT3: case GF_PAINT3:
d = (UINT4)READ_UINTN(fp, (instr - GF_PAINT1 + 1)); d = (UINT4)READ_UINTN( stream, (instr - GF_PAINT1 + 1));
Paint: Paint:
if (paint_sw == 0) if (paint_sw == 0)
{ {
@ -273,18 +256,18 @@ unsigned char bit_table[] = {
case GF_SKIP2: case GF_SKIP2:
case GF_SKIP3: case GF_SKIP3:
m = min_m; m = min_m;
n = n - (UINT4)READ_UINTN(fp, (instr - GF_SKIP1 + 1)) - 1; n = n - (UINT4)READ_UINTN( stream, (instr - GF_SKIP1 + 1)) - 1;
paint_sw = 0; paint_sw = 0;
break; break;
case GF_XXX1: case GF_XXX1:
case GF_XXX2: case GF_XXX2:
case GF_XXX3: case GF_XXX3:
case GF_XXX4: case GF_XXX4:
k = READ_UINTN(fp, instr - GF_XXX1 + 1); k = READ_UINTN( stream, instr - GF_XXX1 + 1);
SKIP_N(fp, k); SKIP_N( stream, k);
break; break;
case GF_YYY: case GF_YYY:
SKIP_N(fp, 4); SKIP_N( stream, 4);
break; break;
case GF_NO_OP: case GF_NO_OP:
break; break;
@ -304,7 +287,8 @@ unsigned char bit_table[] = {
FT_LOCAL_DEF( FT_Error ) FT_LOCAL_DEF( FT_Error )
gf_load_font( FT_Stream stream, gf_load_font( FT_Stream stream,
GF_Face face ) FT_Memory extmemory,
GF_Glyph *goptr )
{ {
GF_Glyph go; GF_Glyph go;
GF_Bitmap bm; GF_Bitmap bm;
@ -314,83 +298,78 @@ unsigned char bit_table[] = {
INT4 w; INT4 w;
UINT4 code; UINT4 code;
double dx, dy; double dx, dy;
long ptr_post, ptr_p, ptr, optr, gptr; long ptr_post, ptr_p, ptr, optr, gptr,tp;
int bc, ec, nchars, i; int bc, ec, nchars, i;
FT_Error error = FT_Err_Ok; FT_Error error = FT_Err_Ok;
FT_Memory memory = extmemory; /* needed for FT_NEW */
FT_FILE *fp = (FT_FILE*)stream->descriptor.pointer ;/* Errors with STREAM_FILE( stream ) FT_ULong offset;
stream->descriptor.pointer is not allocating the file pointer properly*/
go = face->gf_glyph;
char* st = (char*)stream->pathname.pointer;
fp=fopen(st,"rb");
printf("\nHi I am here in gf_load_font 1 stream->pathname: %s %p\n\n", stream->pathname.pointer, *fp);
go = NULL; go = NULL;
nchars = -1; nchars = -1;
/* seek to post_post instr. */
fseek(fp, -5, SEEK_END);
printf("\nHi I am here in gf_load_font -1\n\n"); printf("\nHi I am here in gf_load_font -1\n\n");
/* seek to post_post instr. */
while ((d = READ_UINT1(fp)) == 223) /* fseek(fp, -5, SEEK_END); */
fseek(fp, -2, SEEK_CUR); FT_STREAM_SEEK( stream->size - 5 );
printf("\nHi I am here in gf_load_font 0\n\n"); printf("\nHi I am here in gf_load_font 0\n\n");
printf("\nHi I am here in gf_load_font d instr is %d\n\n",d); while ((d = READ_UINT1( stream )) == 223)
if (d != GF_ID)
{ {
error = FT_THROW( Invalid_File_Format ); FT_STREAM_SEEK( stream->pos -2 );
goto ErrExit; /* fseek(fp, -2, SEEK_CUR); */
} }
printf("\nHi I am here in gf_load_font 1\n\n"); printf("\nHi I am here in gf_load_font 1\n\n");
if (d != GF_ID)
fseek(fp, -6, SEEK_CUR);
/* check if the code is post_post */
if (READ_UINT1(fp) != GF_POST_POST)
{ {
error = FT_THROW( Invalid_File_Format ); error = FT_THROW( Invalid_File_Format );
goto ErrExit; goto ErrExit;
} }
printf("\nHi I am here in gf_load_font 2\n\n"); printf("\nHi I am here in gf_load_font 2\n\n");
/* fseek(fp, -6, SEEK_CUR); */
/* read pointer to post instr. */ FT_STREAM_SEEK( stream->pos -6 );
if ((ptr_post = READ_UINT4(fp)) == -1)
{
error = FT_THROW( Invalid_File_Format );
goto ErrExit;
}
printf("\nHi I am here in gf_load_font 3\n\n"); printf("\nHi I am here in gf_load_font 3\n\n");
/* check if the code is post_post */
/* goto post instr. and read it */ if (READ_UINT1( stream ) != GF_POST_POST)
fseek(fp, ptr_post, SEEK_SET);
if (READ_UINT1(fp) != GF_POST)
{ {
error = FT_THROW( Invalid_File_Format ); error = FT_THROW( Invalid_File_Format );
goto ErrExit; goto ErrExit;
} }
printf("\nHi I am here in gf_load_font 4\n\n"); printf("\nHi I am here in gf_load_font 4\n\n");
/* read pointer to post instr. */
ptr_p = READ_UINT4(fp); if ((ptr_post = gf_read_uint4( stream,4 )) == -1)
ds = READ_UINT4(fp); {
check_sum = READ_UINT4(fp); error = FT_THROW( Invalid_File_Format );
hppp = READ_UINT4(fp); goto ErrExit;
vppp = READ_UINT4(fp); }
min_m = READ_INT4(fp);
max_m = READ_INT4(fp);
min_n = READ_INT4(fp);
max_n = READ_INT4(fp);
printf("\nHi I am here in gf_load_font 5\n\n"); printf("\nHi I am here in gf_load_font 5\n\n");
gptr = ftell(fp); /* goto post instr. and read it */
/* fseek(fp, ptr_post, SEEK_SET); */
FT_STREAM_SEEK( ptr_post );
if (d=READ_UINT1( stream ) != GF_POST)
{
error = FT_THROW( Invalid_File_Format );
goto ErrExit;
}
printf("\nHi I am here in gf_load_font 6\n\n"); printf("\nHi I am here in gf_load_font 6\n\n");
ptr_p = READ_UINT4( stream );
ds = READ_UINT4( stream );
check_sum = READ_UINT4( stream );
hppp = READ_UINT4( stream );
vppp = READ_UINT4( stream );
min_m = READ_INT4( stream );
max_m = READ_INT4( stream );
min_n = READ_INT4( stream );
max_n = READ_INT4( stream );
printf("\nHi I am here in gf_load_font 7\n\n");
#if 0
gptr = ftell(fp);
#endif
#if 0 #if 0
/* read min & max char code */ /* read min & max char code */
@ -429,19 +408,14 @@ printf("\nHi I am here in gf_load_font 6\n\n");
#endif #endif
nchars = ec - bc + 1; nchars = ec - bc + 1;
go= (GF_Glyph)malloc(sizeof(GF_GlyphRec)); /* FT_ALLOC(go, sizeof(GF_GlyphRec)); goto ErrExit; */ go= malloc(sizeof(GF_GlyphRec)); /* FT_ALLOC(go, sizeof(GF_GlyphRec)); goto ErrExit; */
/* Returning unnecessary errors TO BE CHECKED */ /* Returning unnecessary errors TO BE CHECKED */
printf("\nHi I am here in gf_load_font 7\n\n");
go->bm_table = (GF_Bitmap)malloc(nchars* sizeof(GF_BitmapRec));/* FT_ALLOC_MULT(go->bm_table, sizeof(GF_BitmapRec), nchars); goto ErrExit; */ go->bm_table = (GF_Bitmap)malloc(nchars* sizeof(GF_BitmapRec));/* FT_ALLOC_MULT(go->bm_table, sizeof(GF_BitmapRec), nchars); goto ErrExit; */
/* Returning unnecessary errors TO BE CHECKED */ /* Returning unnecessary errors TO BE CHECKED */
printf("\nHi I am here in gf_load_font 8\n\n");
/*for (i = 0; i < nchars; i++) for (i = 0; i < nchars; i++)
go->bm_table[i] = NULL;*/ go->bm_table[i].bitmap = NULL;
printf("\nHi I am here in gf_load_font 9\n\n");
go->ds = (double)ds/(1<<20); go->ds = (double)ds/(1<<20);
go->hppp = (double)hppp/(1<<16); go->hppp = (double)hppp/(1<<16);
@ -458,47 +432,51 @@ printf("\nHi I am here in gf_load_font 9\n\n");
fseek(fp, gptr, SEEK_SET); fseek(fp, gptr, SEEK_SET);
#endif #endif
printf("\nHi I am here in gf_load_font 9.5\n");
for ( ; ; ) for ( ; ; )
{ {
if ((instr = READ_UINT1(fp)) == GF_POST_POST) if ((instr = READ_UINT1( stream )) == GF_POST_POST)
break; break;
printf("\nHi I am here in gf_load_font 9.6 instr is %d\n\n", instr);
switch ((int)instr) switch ((int)instr)
{ {
case GF_CHAR_LOC: case GF_CHAR_LOC:
code = READ_UINT1(fp); code = READ_UINT1( stream );
dx = (double)READ_INT4(fp)/(double)(1<<16); dx = (double)READ_INT4( stream )/(double)(1<<16);
dy = (double)READ_INT4(fp)/(double)(1<<16); dy = (double)READ_INT4( stream )/(double)(1<<16);
w = READ_INT4(fp); w = READ_INT4( stream );
ptr = READ_INT4(fp); ptr = READ_INT4( stream );
break; break;
printf("\nHi I am here in gf_load_font 9.7\n\n");
case GF_CHAR_LOC0: case GF_CHAR_LOC0:
code = READ_UINT1(fp); code = READ_UINT1( stream );
dx = (double)READ_INT1(fp); dx = (double)READ_INT1( stream );
dy = (double)0; dy = (double)0;
w = READ_INT4(fp); w = READ_INT4( stream );
ptr = READ_INT4(fp); ptr = READ_INT4( stream );
break; break;
default: default:
error = FT_THROW( Invalid_File_Format ); error = FT_THROW( Invalid_File_Format );
goto ErrExit; goto ErrExit;
} }
printf("\nHi I am here in gf_load_font 10\n\n");
optr = ft_ftell(fp); /* optr = ft_ftell(fp); */
ft_fseek(fp, ptr, SEEK_SET); optr = stream->pos;
/* ft_fseek(fp, ptr, SEEK_SET); */
FT_STREAM_SEEK( ptr );
bm = &go->bm_table[code - bc]; bm = &go->bm_table[code - bc];
if (gf_read_glyph(fp, bm) < 0) if (gf_read_glyph( stream, bm ) < 0)
goto ErrExit; goto ErrExit;
printf("\nHi I am here in gf_load_font 11\n\n");
bm->mv_x = dx; bm->mv_x = dx;
bm->mv_y = dy; bm->mv_y = dy;
ft_fseek(fp, optr, SEEK_SET); /* ft_fseek(fp, optr, SEEK_SET); */
FT_STREAM_SEEK( ptr );
} }
*goptr = go;
tp = ( go->code_max );
printf("tp go->code_max %d\n",go->code_max);
return error;
ErrExit: ErrExit:
printf("*ERROR\n"); printf("*ERROR\n");
if (go != NULL) if (go != NULL)