[gf] Resolve compiler flag errors.

* src/gf/gflib.c: Remove all the unused variables,
add error checking for all the stream functions which
were raising compiler flag warnings.

* src/gf/gfdrivr.c: Remove unused variables.
This commit is contained in:
Parth Wazurkar 2018-07-02 23:42:38 +05:30
parent 7870984ea1
commit a57dda6564
2 changed files with 99 additions and 98 deletions

View File

@ -23,7 +23,6 @@
#include FT_TRUETYPE_IDS_H
#include FT_SERVICE_FONT_FORMAT_H
#include "gf.h"
#include "gfdrivr.h"
#include "gferror.h"
@ -135,7 +134,7 @@
GF_Face_Done( FT_Face gfface ) /* GF_Face */
{
GF_Face face = (GF_Face)gfface;
FT_Memory memory;
FT_Memory memory= FT_FACE_MEMORY( gfface );
if ( !face )
@ -143,8 +142,7 @@
memory = FT_FACE_MEMORY( face );
gf_free_font( face->gf_glyph, memory );
gf_free_font( gfface, memory );
/* FT_FREE( ); */
}
@ -162,99 +160,77 @@
GF_Glyph go;
int i,count;
face->gf_glyph = &go ;
FT_UNUSED( num_params );
FT_UNUSED( params );
go=NULL;
FT_TRACE2(( "GF driver\n" ));
/* load font */
error = gf_load_font( stream, memory, &go );
if ( error )
goto Exit;
/* we have a gf font: let's construct the face object */
face->gf_glyph = go ;
/* we now need to fill the root FT_Face fields */
/* with relevant information */
/* GF cannot have multiple faces in a single font file.
* XXX: non-zero face_index is already invalid argument, but
* Type1, Type42 driver has a convention to return
* an invalid argument error when the font could be
* opened by the specified driver.
*/
/* if ( face_index > 0 && ( face_index & 0xFFFF ) > 0 )
{
FT_ERROR(( "GF_Face_Init: invalid face index\n" ));
GF_Face_Done( gfface );
return FT_THROW( Invalid_Argument );
}
*/
gfface->num_faces = 1;
gfface->face_index = 0;
gfface->face_flags |= FT_FACE_FLAG_FIXED_SIZES |
gfface->num_faces = 1;
gfface->face_index = 0;
gfface->face_flags |= FT_FACE_FLAG_FIXED_SIZES |
FT_FACE_FLAG_HORIZONTAL ;
/*
* XXX: TO-DO: gfface->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
* XXX: I have to check for this.
*/
printf("Hi I am here2\n");
gfface->family_name = NULL;
gfface->family_name = NULL;
count=0;
for (i = 0; i < 256; i++)
{
if(go->bm_table[i].bitmap != NULL)
count++;
}
printf("count is %d",count);
gfface->num_glyphs = (FT_Long)count;
gfface->num_glyphs = (FT_Long)count;printf("count is %d", count);
gfface->num_fixed_sizes = 1;
printf("Hi I am here3\n");
if ( FT_NEW_ARRAY( gfface->available_sizes, 1 ) )
goto Exit;
printf("Hi I am here4\n");
{
FT_Bitmap_Size* bsize = gfface->available_sizes;
FT_UShort x_res, y_res;
FT_ZERO( bsize );
bsize->width = (FT_Short) face->gf_glyph->font_bbx_w ;
bsize->height = (FT_Short) face->gf_glyph->font_bbx_h ;
bsize->size = (FT_Short) face->gf_glyph->ds ; /* Preliminary to be checked for 26.6 fractional points*/
bsize->width = (FT_Short) face->gf_glyph->font_bbx_w ;
bsize->height = (FT_Short) face->gf_glyph->font_bbx_h ;
bsize->size = (FT_Short) face->gf_glyph->ds ; /* Preliminary to be checked for 26.6 fractional points*/
/*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->x_ppem = face->gf_glyph->font_bbx_xoff ;
}
printf("Hi I am here5\n");
/* Charmaps */
{
FT_CharMapRec charmap;
{
FT_CharMapRec charmap;
charmap.encoding = FT_ENCODING_NONE;
/* initial platform/encoding should indicate unset status? */
charmap.platform_id = TT_PLATFORM_APPLE_UNICODE; /*Preliminary */
charmap.encoding_id = TT_APPLE_ID_DEFAULT;
charmap.face = face;
charmap.encoding = FT_ENCODING_NONE;
/* initial platform/encoding should indicate unset status? */
charmap.platform_id = TT_PLATFORM_APPLE_UNICODE; /*Preliminary */
charmap.encoding_id = TT_APPLE_ID_DEFAULT;
charmap.face = FT_FACE( face );
error = FT_CMap_New( &gf_cmap_class, NULL, &charmap, NULL );
error = FT_CMap_New( &gf_cmap_class, NULL, &charmap, NULL );
if ( error )
goto Fail;
}
if ( error )
goto Fail;
printf("Hi I am here completed GF_Face_Init1\n");
}
printf("Hi I am here6\n");
Fail:
/* GF_Face_Done( gfface ); */
GF_Face_Done( gfface );
Exit:
printf("Hi I am here completed GF_Face_Init2 %ld\n",gfface->num_glyphs);
return error;
}
@ -263,14 +239,15 @@ printf("Hi I am here6\n");
FT_ULong strike_index )
{
GF_Face face = (GF_Face)size->face;
FT_UNUSED( strike_index );
FT_Select_Metrics( size->face, 0 );
size->metrics.ascender = face->gf_glyph->font_bbx_xoff * 64 ;
size->metrics.descender = face->gf_glyph->font_bbx_yoff * 64 ;
size->metrics.max_advance = face->gf_glyph->font_bbx_w * 64 ;
size->metrics.ascender = face->gf_glyph->font_bbx_xoff * 64;
size->metrics.descender = face->gf_glyph->font_bbx_yoff * 64;
size->metrics.max_advance = face->gf_glyph->font_bbx_w * 64;
return FT_Err_Ok;
@ -295,10 +272,12 @@ printf("Hi I am here6\n");
if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
error = FT_Err_Ok;
break;
case FT_SIZE_REQUEST_TYPE_REAL_DIM:
if ( height == face->gf_glyph->font_bbx_h ) /* Preliminary */
error = FT_Err_Ok;
break;
default:
error = FT_THROW( Unimplemented_Feature );
break;
@ -326,8 +305,10 @@ printf("Hi I am here6\n");
GF_Glyph go;
go = gf->gf_glyph;
FT_UNUSED( load_flags );
if ( !face )
{
error = FT_THROW( Invalid_Face_Handle );
@ -360,7 +341,7 @@ printf("Hi I am here6\n");
/* note: we don't allocate a new array to hold the bitmap; */
/* we can simply point to it */
ft_glyphslot_set_bitmap( slot, bm.bitmap );
ft_glyphslot_set_bitmap( slot, bm.bitmap ); /* TO CHECK for column and row? like winfont.*/
slot->format = FT_GLYPH_FORMAT_BITMAP;
slot->bitmap_left = bm.off_x ; /* Prelimiary */

View File

@ -64,12 +64,13 @@ unsigned char bit_table[] = {
gf_read_uintn(FT_Stream stream, int size)
{
unsigned long v,k;
FT_Error error = FT_Err_Ok;
FT_Error error;
FT_Byte tp;
v = 0L;
while (size >= 1)
{
FT_READ_BYTE(tp);
if ( FT_READ_BYTE(tp) )
return 0; /* To be changed */
k =(unsigned long)tp;
v = v*256L + k;
--size;
@ -82,9 +83,10 @@ unsigned char bit_table[] = {
{
long v;
FT_Byte tp;
FT_Error error= FT_Err_Ok;
FT_Error error;
unsigned long z ;
FT_READ_BYTE(tp);
if ( FT_READ_BYTE(tp) )
return 0;/* To be changed */
z= (unsigned long)tp;
v = (long)z & 0xffL;
if (v & 0x80L)
@ -92,7 +94,8 @@ unsigned char bit_table[] = {
--size;
while (size >= 1)
{
FT_READ_BYTE(tp);
if ( FT_READ_BYTE(tp) )
return 0;/* To be changed */
z= (unsigned long)tp;
v = v*256L + z;
--size;
@ -121,15 +124,19 @@ unsigned char bit_table[] = {
switch (READ_UINT1( stream ))
{
case GF_BOC:
FT_STREAM_SKIP( 4 );
FT_STREAM_SKIP( 4 );
if ( FT_STREAM_SKIP( 4 ) )
return -1;
if ( FT_STREAM_SKIP( 4 ) )
return -1;
min_m = READ_INT4( stream );
max_m = READ_INT4( stream );
min_n = READ_INT4( stream );
max_n = READ_INT4( stream );
break;
case GF_BOC1:
FT_STREAM_SKIP( 1 );
if ( FT_STREAM_SKIP( 1 ) )
return -1;
del_m = (INT4)READ_UINT1( stream );
max_m = (INT4)READ_UINT1( stream );
del_n = (INT4)READ_UINT1( stream );
@ -137,10 +144,13 @@ unsigned char bit_table[] = {
min_m = max_m - del_m;
min_n = max_n - del_n;
break;
default:
return -1;
}
if(error != FT_Err_Ok)
return -1;
w = max_m - min_m + 1;
h = max_n - min_n + 1;
if ((w < 0) || (h < 0))
@ -234,10 +244,12 @@ unsigned char bit_table[] = {
case GF_XXX3:
case GF_XXX4:
k = READ_UINTN( stream, instr - GF_XXX1 + 1);
FT_STREAM_SKIP( k );
if ( FT_STREAM_SKIP( k ) )
return -1;
break;
case GF_YYY:
FT_STREAM_SKIP( 4 );
if ( FT_STREAM_SKIP( 4 ) )
return -1;
break;
case GF_NO_OP:
break;
@ -266,25 +278,31 @@ unsigned char bit_table[] = {
INT4 w;
UINT4 code;
double dx, dy;
long ptr_post, ptr_p, ptr, optr, gptr;
long ptr_post, ptr_p, ptr, optr;
int bc, ec, nchars, i;
FT_Error error = FT_Err_Ok, error1;
FT_Error error = FT_Err_Ok;
FT_Memory memory = extmemory; /* needed for FT_NEW */
FT_ULong offset;
FT_Byte tp;
go = NULL;
nchars = -1;
/* seek to post_post instr. */
/* fseek(fp, -1, SEEK_END); */
FT_STREAM_SEEK( stream->size - 1 );
if( FT_STREAM_SEEK( stream->size - 1 ) )
goto ErrExit;
if( FT_STREAM_SEEK( stream->size - 1 ) )
goto ErrExit;
while ( d= READ_UINT1( stream ) == 223)
FT_STREAM_SEEK( stream->pos -2 );
while ( READ_UINT1( stream ) == 223)
{
if( FT_STREAM_SEEK( stream->pos -2 ) )
goto ErrExit;
/* fseek(fp, -2, SEEK_CUR); */
}
FT_STREAM_SEEK( stream->pos -1 );
if( FT_STREAM_SEEK( stream->pos -1 ) )
goto ErrExit;
d= READ_UINT1( stream );
if (d != GF_ID)
@ -294,7 +312,8 @@ unsigned char bit_table[] = {
}
/* fseek(fp, -6, SEEK_CUR); */
FT_STREAM_SEEK( stream->pos -6 );
if(FT_STREAM_SEEK( stream->pos -6 ))
goto ErrExit;
/* check if the code is post_post */
if (READ_UINT1( stream ) != GF_POST_POST)
@ -304,7 +323,9 @@ unsigned char bit_table[] = {
}
/* read pointer to post instr. */
FT_READ_ULONG( ptr_post );
if(FT_READ_ULONG( ptr_post ))
goto ErrExit;
if (ptr_post == -1)
{
error = FT_THROW( Invalid_File_Format );
@ -313,18 +334,25 @@ unsigned char bit_table[] = {
/* goto post instr. and read it */
/* fseek(fp, ptr_post, SEEK_SET); */
FT_STREAM_SEEK( ptr_post );
if(FT_STREAM_SEEK( ptr_post ))
goto ErrExit;
if (READ_UINT1( stream ) != GF_POST)
{
error = FT_THROW( Invalid_File_Format );
goto ErrExit;
}
FT_READ_ULONG( ptr_p ) ;
FT_READ_ULONG( ds ) ;
FT_READ_ULONG( check_sum );
FT_READ_ULONG( hppp ) ;
FT_READ_ULONG( vppp ) ;
if(FT_READ_ULONG( ptr_p ))
goto ErrExit;
if(FT_READ_ULONG( ds ))
goto ErrExit;
if(FT_READ_ULONG( check_sum ))
goto ErrExit;
if(FT_READ_ULONG( hppp ))
goto ErrExit;
if(FT_READ_ULONG( vppp ))
goto ErrExit;
min_m = READ_INT4( stream );
max_m = READ_INT4( stream );
min_n = READ_INT4( stream );
@ -425,7 +453,8 @@ unsigned char bit_table[] = {
/* optr = ft_ftell(fp); */
optr = stream->pos;
/* ft_fseek(fp, ptr, SEEK_SET); */
FT_STREAM_SEEK( ptr );
if( FT_STREAM_SEEK( ptr ) )
goto ErrExit;
bm = &go->bm_table[code - bc];
if (gf_read_glyph( stream, bm, memory ) < 0)
@ -434,7 +463,8 @@ unsigned char bit_table[] = {
bm->mv_x = dx;
bm->mv_y = dy;
/* ft_fseek(fp, optr, SEEK_SET); */
FT_STREAM_SEEK( optr );
if(FT_STREAM_SEEK( optr ))
goto ErrExit;
}
*goptr = go;
return error;
@ -460,17 +490,7 @@ unsigned char bit_table[] = {
GF_Face gf = (GF_Face)gfface;
GF_Glyph go;
go = gf->gf_glyph;
int i=0, nchars =gfface->num_glyphs;
if (go != NULL)
{
if (go->bm_table != NULL)
{
for (i = 0; i < nchars; i++){}
/* FT_FREE(go->bm_table[i].bitmap); */
}
/* FT_FREE(go->bm_table); */
}
/* FT_FREE(go); */
}