summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParth Wazurkar <parthwazurkar@gmail.com>2018-06-27 21:50:33 +0530
committerParth Wazurkar <parthwazurkar@gmail.com>2018-07-03 01:57:10 +0530
commit86cc6cbd4095b79b2216614c3de10f0368ca71d8 (patch)
tree6e58dff0b6ea97bda2af555bf9d8032bf7e022ad
parent5585c5f3657a82458049acc7a7ec8e3a14478861 (diff)
downloadfreetype2-86cc6cbd4095b79b2216614c3de10f0368ca71d8.tar.gz
[gf] Changes.
-rw-r--r--src/gf/gfdrivr.c123
-rw-r--r--src/gf/gflib.c160
-rw-r--r--src/gf/gflibfp.c478
3 files changed, 113 insertions, 648 deletions
diff --git a/src/gf/gfdrivr.c b/src/gf/gfdrivr.c
index 1d2f0ff28..1f0eaedaa 100644
--- a/src/gf/gfdrivr.c
+++ b/src/gf/gfdrivr.c
@@ -23,7 +23,6 @@
#include FT_TRUETYPE_IDS_H
#include FT_SERVICE_FONT_FORMAT_H
-
#include "gf.h"
#include "gfdrivr.h"
#include "gferror.h"
@@ -134,7 +133,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,6 @@
memory = FT_FACE_MEMORY( face );
gf_free_font( face->gf_glyph, memory );
-
- /* FT_FREE( ); */
}
@@ -167,83 +164,60 @@
FT_TRACE2(( "GF driver\n" ));
/* 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");
-
+ error = gf_load_font( stream, memory, &go );
if ( error )
goto Exit;
- /* we have a gf font: let's construct the face object */
+ /* 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 |
- 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->num_glyphs = (FT_Long)(go->code_max - go->code_min + 1 );
+ gfface->num_faces = 1;
+ gfface->face_index = 0;
+ gfface->face_flags |= FT_FACE_FLAG_FIXED_SIZES | FT_FACE_FLAG_HORIZONTAL ;
+ gfface->family_name = NULL;
+ gfface->num_glyphs = (FT_Long)(go->code_max - go->code_min + 1 );
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*/
-
- /*x_res = ; To be Checked for x_resolution and y_resolution
- 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");
+
+ {
+ FT_Bitmap_Size* bsize = gfface->available_sizes;
+ FT_UShort x_res, y_res;
+
+ 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 = ;*/
+
+ bsize->y_ppem = face->gf_glyph->font_bbx_yoff ;
+ bsize->x_ppem = face->gf_glyph->font_bbx_xoff ;
+ }
/* 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 = 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;
}
@@ -252,14 +226,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;
@@ -284,10 +259,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;
@@ -315,7 +292,6 @@ printf("Hi I am here6\n");
FT_UNUSED( load_flags );
- printf("Hi I am here in gf_load_glyphs");
if ( !face )
{
@@ -331,11 +307,12 @@ printf("Hi I am here6\n");
FT_TRACE1(( "GF_Glyph_Load: glyph index %d\n", glyph_index ));
- /*if ( glyph_index > 0 )
+ #if 0
+ if ( glyph_index > 0 )
glyph_index--;
else
- glyph_index = 0;
- */
+ glyph_index = /* */;
+ #endif
if ( glyph_index < 0 )
glyph_index = 0;
@@ -345,7 +322,7 @@ printf("Hi I am here6\n");
bitmap->rows = bm.mv_y ; /* Prelimiary */
bitmap->width = bm.mv_x ; /* Prelimiary */
- /*bitmap->pitch = bm ; *//* Prelimiary */
+ /* bitmap->pitch = ; */
/* note: we don't allocate a new array to hold the bitmap; */
/* we can simply point to it */
@@ -361,7 +338,7 @@ printf("Hi I am here6\n");
slot->metrics.width = (FT_Pos) ( bitmap->width * 64 ) ; /* Prelimiary */
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, bm.bbx_height * 64 );
Exit:
return error;
diff --git a/src/gf/gflib.c b/src/gf/gflib.c
index 733d90c18..c44d51804 100644
--- a/src/gf/gflib.c
+++ b/src/gf/gflib.c
@@ -43,28 +43,37 @@
unsigned char bit_table[] = {
0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
+ /**************************************************************************
+ *
+ * GF font utility functions.
+ *
+ */
+
long gf_read_intn(FT_Stream,int);
- void gf_skip_n(FT_Stream,int);
+ unsigned long gf_read_uintn(FT_Stream,int);
-#define READ_INT1( stream ) (INT1)gf_read_intn(( stream ), 1)
-#define READ_INT2( stream ) (INT2)gf_read_intn(( stream ), 2)
-#define READ_INT3( stream ) (INT3)gf_read_intn(( stream ), 3)
-#define READ_INT4( stream ) (INT4)gf_read_intn(( stream ), 4)
-#define READ_INTN( stream ,n) (INT4)gf_read_intn(( stream ), (n))
-#define SKIP_N( stream ,k) gf_skip_n(( stream ), (k))
-#define READ_UINTN( stream ,n) (UINT4)gf_read_uintn(( stream ), (n))
+#define READ_UINT1( stream ) (UINT1)gf_read_uintn( stream, 1)
+#define READ_UINTN( stream,n) (UINT4)gf_read_uintn( stream, n)
+#define READ_INT1( stream ) (INT1)gf_read_intn( stream, 1)
+#define READ_INT4( stream ) (INT4)gf_read_intn( stream, 4)
/*
- * Reading a Number from stream
+ * Reading a Number from file
*/
unsigned long
- READ_UINT1(FT_Stream stream)
+ gf_read_uintn(FT_Stream stream, int size)
{
unsigned long v,k;
- FT_Error error= FT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
FT_Byte tp;
- FT_READ_BYTE(tp);
- v =(unsigned long)tp;
+ v = 0L;
+ while (size >= 1)
+ {
+ FT_READ_BYTE(tp);
+ k =(unsigned long)tp;
+ v = v*256L + k;
+ --size;
+ }
return v;
}
@@ -91,36 +100,6 @@ unsigned char bit_table[] = {
return v;
}
- unsigned long
- gf_read_uintn(FT_Stream stream, int size)
- {
- unsigned long v,k;
- FT_Error error = FT_Err_Ok;
- FT_Byte tp;
- v = 0L;
- while (size >= 1)
- {
- FT_READ_BYTE(tp);
- k =(unsigned long)tp;
- v = v*256L + (unsigned long)k;
- --size;
- }
- return v;
- }
-
- void
- gf_skip_n(FT_Stream stream, int size)
- {
- FT_Stream_Skip(stream, (FT_Long)size );
- #if 0
- while (size > 0)
- {
- (void)getc(fp);
- --size;
- }
- #endif
- }
-
/**************************************************************************
*
* API.
@@ -128,7 +107,7 @@ unsigned char bit_table[] = {
*/
FT_LOCAL_DEF( FT_Error )
- gf_read_glyph(FT_Stream stream, GF_Bitmap bm)
+ gf_read_glyph(FT_Stream stream, GF_Bitmap bm, FT_Memory memory)
{
long m, n;
int paint_sw;
@@ -137,29 +116,29 @@ unsigned char bit_table[] = {
long w, h, d;
int m_b, k;
unsigned char *ptr;
- FT_Error error = FT_Err_Ok;
+ FT_Error error = FT_Err_Ok;
switch (READ_UINT1( stream ))
{
case GF_BOC:
- SKIP_N( stream , 4);
- SKIP_N( stream , 4);
+ FT_STREAM_SKIP( 4 );
+ FT_STREAM_SKIP( 4 );
min_m = READ_INT4( stream );
max_m = READ_INT4( stream );
min_n = READ_INT4( stream );
max_n = READ_INT4( stream );
-
break;
+
case GF_BOC1:
- SKIP_N( stream , 1);
+ FT_STREAM_SKIP( 1 );
del_m = (INT4)READ_UINT1( stream );
max_m = (INT4)READ_UINT1( stream );
del_n = (INT4)READ_UINT1( stream );
max_n = (INT4)READ_UINT1( stream );
min_m = max_m - del_m;
min_n = max_n - del_n;
-
break;
+
default:
return -1;
}
@@ -240,7 +219,7 @@ unsigned char bit_table[] = {
}
paint_sw = 1 - paint_sw;
break;
- case GF_SKIP0:
+ case GF_SKIP0:
m = min_m;
n = n - 1;
paint_sw = 0;
@@ -257,23 +236,22 @@ unsigned char bit_table[] = {
case GF_XXX3:
case GF_XXX4:
k = READ_UINTN( stream, instr - GF_XXX1 + 1);
- SKIP_N( stream, k);
+ FT_STREAM_SKIP( k );
break;
case GF_YYY:
- SKIP_N( stream, 4);
+ FT_STREAM_SKIP( 4 );
break;
case GF_NO_OP:
break;
default:
- /* FT_FREE(bm->bitmap); */ /* Returning unnecessary errors TO BE CHECKED */
+ FT_FREE(bm->bitmap);
bm->bitmap = NULL;
error = FT_THROW( Invalid_File_Format );
return -1;
}
}
}
-
- return 0;
+ return 0;
}
@@ -301,16 +279,13 @@ unsigned char bit_table[] = {
nchars = -1;
/* seek to post_post instr. */
- /* fseek(fp, -5, SEEK_END); */
+ /* fseek(fp, -1, SEEK_END); */
FT_STREAM_SEEK( stream->size - 1 );
-
while ( d= READ_UINT1( stream ) == 223)
- {
FT_STREAM_SEEK( stream->pos -2 );
-
/* fseek(fp, -2, SEEK_CUR); */
- }
+
FT_STREAM_SEEK( stream->pos -1 );
d= READ_UINT1( stream );
@@ -320,20 +295,16 @@ unsigned char bit_table[] = {
goto ErrExit;
}
-
/* fseek(fp, -6, SEEK_CUR); */
FT_STREAM_SEEK( stream->pos -6 );
-
/* check if the code is post_post */
-
if (READ_UINT1( stream ) != GF_POST_POST)
{
error = FT_THROW( Invalid_File_Format );
goto ErrExit;
}
-
/* read pointer to post instr. */
FT_READ_ULONG( ptr_post );
if (ptr_post == -1)
@@ -342,30 +313,27 @@ unsigned char bit_table[] = {
goto ErrExit;
}
-
/* goto post instr. and read it */
/* fseek(fp, ptr_post, SEEK_SET); */
FT_STREAM_SEEK( ptr_post );
-
if (READ_UINT1( stream ) != GF_POST)
{
error = FT_THROW( Invalid_File_Format );
goto ErrExit;
}
-
- FT_READ_ULONG( ptr_p ) ;printf("\nptr_p is %d\n",ptr_p);
- FT_READ_ULONG( ds ) ;printf("\nds is %d\n",ds);
- FT_READ_ULONG( check_sum );printf("\ncheck_sum is %d\n",check_sum);
- FT_READ_ULONG( hppp ) ;printf("\nhppp is %d\n",hppp);
- FT_READ_ULONG( vppp ) ;printf("\nvppp is %d\n",vppp);
- min_m = READ_INT4( stream );printf("\nmin_m is %d\n",min_m);
- max_m = READ_INT4( stream );printf("\nmax_m is %d\n",max_m);
- min_n = READ_INT4( stream );printf("\nmin_n is %d\n",min_n);
- max_n = READ_INT4( stream );printf("\nmax_n is %d\n",max_n);
+ FT_READ_ULONG( ptr_p ) ;
+ FT_READ_ULONG( ds ) ;
+ FT_READ_ULONG( check_sum );
+ FT_READ_ULONG( hppp ) ;
+ FT_READ_ULONG( vppp ) ;
+ min_m = READ_INT4( stream );
+ max_m = READ_INT4( stream );
+ min_n = READ_INT4( stream );
+ max_n = READ_INT4( stream );
#if 0
- gptr = ftell(fp);
+ gptr = ftell(fp);
#endif
#if 0
@@ -409,24 +377,22 @@ unsigned char bit_table[] = {
if( FT_ALLOC(go, sizeof(GF_GlyphRec)) )
goto ErrExit;
-
/*go->bm_table = (GF_Bitmap)malloc(nchars* sizeof(GF_BitmapRec));*/
if( FT_ALLOC_MULT(go->bm_table, sizeof(GF_BitmapRec), nchars) )
goto ErrExit;
-
for (i = 0; i < nchars; i++)
go->bm_table[i].bitmap = NULL;
- go->ds = (double)ds/(1<<20);printf("\ngo->ds is %d\n",go->ds);
- go->hppp = (double)hppp/(1<<16);printf("\ngo->hppp is %d\n",go->hppp);
- go->vppp = (double)vppp/(1<<16);printf("\ngo->vppp is %d\n",go->vppp);
- go->font_bbx_w = max_m - min_m;printf("\ngo->font_bbx_w is %d\n",go->font_bbx_w);
- go->font_bbx_h = max_n - min_n;printf("\ngo->font_bbx_h is %d\n",go->font_bbx_h);
- go->font_bbx_xoff = min_m;printf("\ngo->font_bbx_xoff is %d\n",go->font_bbx_xoff);
- go->font_bbx_yoff = min_n;printf("\ngo->font_bbx_yoff is %d\n",go->font_bbx_yoff);
- go->code_min = bc;printf("\ngo->code_min is %d\n",go->code_min);
- go->code_max = ec;printf("\ngo->code_max is %d\n",go->code_max);
+ go->ds = (double)ds/(1<<20);
+ go->hppp = (double)hppp/(1<<16);
+ go->vppp = (double)vppp/(1<<16);
+ go->font_bbx_w = max_m - min_m;
+ go->font_bbx_h = max_n - min_n;
+ go->font_bbx_xoff = min_m;
+ go->font_bbx_yoff = min_n;
+ go->code_min = bc;
+ go->code_max = ec;
/* read glyph */
#if 0
@@ -447,11 +413,11 @@ unsigned char bit_table[] = {
ptr = READ_INT4( stream );
break;
case GF_CHAR_LOC0:
- code = READ_UINT1( stream );printf("code is %d\n",code);
- dx = (double)READ_INT1( stream );printf("dx is %d\n",dx);
+ code = READ_UINT1( stream );
+ dx = (double)READ_INT1( stream );
dy = (double)0;
- w = READ_INT4( stream );printf("w is %d\n",w);
- ptr = READ_INT4( stream );printf("ptr is %d\n",ptr);
+ w = READ_INT4( stream );
+ ptr = READ_INT4( stream );
break;
default:
error = FT_THROW( Invalid_File_Format );
@@ -464,7 +430,7 @@ unsigned char bit_table[] = {
FT_STREAM_SEEK( ptr );
bm = &go->bm_table[code - bc];
- if (gf_read_glyph( stream, bm ) < 0)
+ if (gf_read_glyph( stream, bm, memory ) < 0)
goto ErrExit;
bm->mv_x = dx;
@@ -473,7 +439,6 @@ unsigned char bit_table[] = {
FT_STREAM_SEEK( optr );
}
*goptr = go;
-printf("\nHi I was here in gf_load_font\n");
return error;
ErrExit:
@@ -488,11 +453,12 @@ printf("\nHi I was here in gf_load_font\n");
FT_FREE(go->bm_table);
}
FT_FREE(go);
+ return NULL;
}
FT_LOCAL_DEF( void )
- gf_free_font( GF_Glyph go, FT_Memory memory)
+ gf_free_font( GF_Glyph go, FT_Memory memory )
{
int i=0, nchars =sizeof(go->bm_table);
if (go != NULL)
@@ -500,7 +466,7 @@ printf("\nHi I was here in gf_load_font\n");
if (go->bm_table != NULL)
{
for (i = 0; i < nchars; i++)
- FT_FREE(go->bm_table[i].bitmap); /* To be verified from Vflib */
+ FT_FREE(go->bm_table[i].bitmap);
}
FT_FREE(go->bm_table);
}
diff --git a/src/gf/gflibfp.c b/src/gf/gflibfp.c
deleted file mode 100644
index 5be132d3a..000000000
--- a/src/gf/gflibfp.c
+++ /dev/null
@@ -1,478 +0,0 @@
-/****************************************************************************
- *
- * gflib.c
- *
- * FreeType font driver for TeX's GF FONT files
- *
- * Copyright 1996-2018 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- */
-
-#include <ft2build.h>
-
-#include FT_FREETYPE_H
-#include FT_INTERNAL_DEBUG_H
-#include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_OBJECTS_H
-#include FT_SYSTEM_H
-#include FT_CONFIG_CONFIG_H
-#include FT_ERRORS_H
-#include FT_TYPES_H
-
-#include "gf.h"
-#include "gfdrivr.h"
-#include "gferror.h"
-
-
- /**************************************************************************
- *
- * The macro FT_COMPONENT is used in trace mode. It is an implicit
- * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
- * messages during execution.
- */
-#undef FT_COMPONENT
-#define FT_COMPONENT trace_gflib
-
-unsigned char bit_table[] = {
- 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
-
-#define STREAM_FILE( stream ) ( (FT_FILE*)stream->descriptor.pointer )
-
- /**************************************************************************
- *
- * GF font utility functions.
- *
- */
-
- long gf_read_intn(FILE*,int);
- unsigned long gf_read_uintn(FILE*,int);
- void gf_skip_n(FILE*,int);
-
-#define READ_INT1(fp) (INT1)gf_read_intn((fp), 1)
-#define READ_UINT1(fp) (UINT1)gf_read_uintn((fp), 1)
-#define READ_INT2(fp) (INT2)gf_read_intn((fp), 2)
-#define READ_UINT2(fp) (UINT2)gf_read_uintn((fp), 2)
-#define READ_INT3(fp) (INT3)gf_read_intn((fp), 3)
-#define READ_UINT3(fp) (UINT3)gf_read_uintn((fp), 3)
-#define READ_INT4(fp) (INT4)gf_read_intn((fp), 4)
-#define READ_UINT4(fp) (UINT4)gf_read_uintn((fp), 4)
-#define READ_INTN(fp,n) (INT4)gf_read_intn((fp), (n))
-#define READ_UINTN(fp,n) (UINT4)gf_read_uintn((fp), (n))
-#define SKIP_N(fp,k) gf_skip_n((fp), (k))
-
-
-/*
- * Reading a Number from file
- */
- unsigned long
- gf_read_uintn(FILE* fp, int size)
- {
- unsigned long v ;
- v = 0L;
- while (size >= 1)
- {
- v = v*256L + (unsigned long)getc(fp);
- --size;
- }
- return v;
- }
-
- long
- gf_read_intn(FILE* fp, int size)
- {
- long v;
- v = (long)getc(fp) & 0xffL;
- if (v & 0x80L)
- v = v - 256L;
- --size;
- while (size >= 1)
- {
- v = v*256L + (unsigned long)getc(fp);
- --size;
- }
- return v;
- }
-
- void
- gf_skip_n(FILE* fp, int size)
- {
- while (size > 0)
- {
- (void)getc(fp);
- --size;
- }
- }
-
- /**************************************************************************
- *
- * API.
- *
- */
-
- FT_LOCAL_DEF( FT_Error )
- gf_read_glyph(FT_FILE* fp, GF_Bitmap bm)
- {
- long m, n;
- int paint_sw;
- int instr;
- INT4 min_m, max_m, min_n, max_n, del_m, del_n;
- long w, h, d;
- int m_b, k;
- unsigned char *ptr;
- FT_Error error = FT_Err_Ok;
-
- switch (READ_UINT1(fp))
- {
- case GF_BOC:
- SKIP_N(fp, 4);
- SKIP_N(fp, 4);
- min_m = READ_INT4(fp);
- max_m = READ_INT4(fp);
- min_n = READ_INT4(fp);
- max_n = READ_INT4(fp);
- break;
- case GF_BOC1:
- SKIP_N(fp, 1);
- del_m = (INT4)READ_UINT1(fp);
- max_m = (INT4)READ_UINT1(fp);
- del_n = (INT4)READ_UINT1(fp);
- max_n = (INT4)READ_UINT1(fp);
- min_m = max_m - del_m;
- min_n = max_n - del_n;
- break;
- default:
- goto Exit;
- }
-
- w = max_m - min_m + 1;
- h = max_n - min_n + 1;
- if ((w < 0) || (h < 0))
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- if ((bm->bitmap = (unsigned char*)malloc(h*((w+7)/8))) == NULL)
- {
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
-
- memset(bm->bitmap, 0, h*((w+7)/8));
- bm->raster = (w+7)/8;
- bm->bbx_width = w;
- bm->bbx_height = h;
- bm->off_x = -min_m;
- bm->off_y = max_n;
- #if 0
- bm->mv_x = -min_m;
- bm->mv_y = max_n;
- #endif
-
- m = min_m;
- n = max_n;
- paint_sw = 0;
- while ((instr = (int)READ_UINT1(fp)) != GF_EOC)
- {
- if (instr == GF_PAINT_0)
- {
- paint_sw = 1 - paint_sw;
- }
- else if ((GF_NEW_ROW_0 <= instr) && (instr <= GF_NEW_ROW_164))
- {
- m = min_m + (instr - GF_NEW_ROW_0);
- n = n - 1;
- paint_sw = 1;
- }
- else if ((GF_PAINT_1 <= instr) && (instr <= GF_PAINT_63))
- {
- d = (instr - GF_PAINT_1 + 1);
- goto Paint;
- }
- else
- {
- switch ((int)instr)
- {
- case GF_PAINT1:
- case GF_PAINT2:
- case GF_PAINT3:
- d = (UINT4)READ_UINTN(fp, (instr - GF_PAINT1 + 1));
- Paint:
- if (paint_sw == 0)
- {
- m = m + d;
- }
- else
- {
- ptr = &bm->bitmap[(max_n - n) * bm->raster + (m - min_m)/8];
- m_b = (m - min_m) % 8;
- while (d > 0)
- {
- *ptr |= bit_table[m_b];
- m++;
- if (++m_b >= 8)
- {
- m_b = 0;
- ++ptr;
- }
- d--;
- }
- }
- paint_sw = 1 - paint_sw;
- break;
- case GF_SKIP0:
- m = min_m;
- n = n - 1;
- paint_sw = 0;
- break;
- case GF_SKIP1:
- case GF_SKIP2:
- case GF_SKIP3:
- m = min_m;
- n = n - (UINT4)READ_UINTN(fp, (instr - GF_SKIP1 + 1)) - 1;
- paint_sw = 0;
- break;
- case GF_XXX1:
- case GF_XXX2:
- case GF_XXX3:
- case GF_XXX4:
- k = READ_UINTN(fp, instr - GF_XXX1 + 1);
- SKIP_N(fp, k);
- break;
- case GF_YYY:
- SKIP_N(fp, 4);
- break;
- case GF_NO_OP:
- break;
- default:
- /* FT_FREE(bm->bitmap); */ /* Returning unnecessary errors TO BE CHECKED */
- bm->bitmap = NULL;
- error = FT_THROW( Invalid_File_Format );
- goto Exit;
- }
- }
- }
-
- Exit:
- return error;
- }
-
-
- FT_LOCAL_DEF( FT_Error )
- gf_load_font( FT_Stream stream,
- FT_Memory extmemory,
- GF_Glyph *goptr )
- {
- GF_Glyph go;
- GF_Bitmap bm;
- UINT1 instr, d;
- UINT4 ds, check_sum, hppp, vppp;
- INT4 min_m, max_m, min_n, max_n;
- INT4 w;
- UINT4 code;
- double dx, dy;
- long ptr_post, ptr_p, ptr, optr, gptr,tp;
- int bc, ec, nchars, i;
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = extmemory; /* needed for FT_NEW */
- FT_ULong offset;
-
- FT_FILE *fp = STREAM_FILE( stream ) ;
-
- go = NULL;
- nchars = -1;
-
- char* st = (char*)stream->pathname.pointer;
- fp=fopen(st,"rb");
-printf("\nHi I am here in gflibfp\n");
- /* seek to post_post instr. */
- fseek(fp, -5, SEEK_END);
-
- while ((d = READ_UINT1(fp)) == 223)
- fseek(fp, -2, SEEK_CUR);
-
- if (d != GF_ID)
- {
- error = FT_THROW( Invalid_File_Format );
- goto ErrExit;
- }
-
- 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 );
- goto ErrExit;
- }
-
- /* read pointer to post instr. */
- if ((ptr_post = READ_UINT4(fp)) == -1)
- {
- error = FT_THROW( Invalid_File_Format );
- goto ErrExit;
- }
-
- /* goto post instr. and read it */
- fseek(fp, ptr_post, SEEK_SET);
- if (READ_UINT1(fp) != GF_POST)
- {
- error = FT_THROW( Invalid_File_Format );
- goto ErrExit;
- }
-
- ptr_p = READ_UINT4(fp);printf("\nptr_p is %d\n",ptr_p);
- ds = READ_UINT4(fp);printf("\nds is %d\n",ds);
- check_sum = READ_UINT4(fp);printf("\ncheck_sum is %d\n",check_sum);
- hppp = READ_UINT4(fp);printf("\nhppp is %d\n",hppp);
- vppp = READ_UINT4(fp);printf("\nvppp is %d\n",vppp);
- min_m = READ_INT4(fp);printf("\nmin_m is %d\n",min_m);
- max_m = READ_INT4(fp);printf("\nmax_m is %d\n",max_m);
- min_n = READ_INT4(fp);printf("\nmin_n is %d\n",min_n);
- max_n = READ_INT4(fp);printf("\nmax_n is %d\n",max_n);
-
- gptr = ftell(fp);
-
- #if 0
- /* read min & max char code */
- bc = 256;
- ec = -1;
- for ( ; ; )
- {
- instr = READ_UINT1(fp);
- if (instr == GF_POST_POST)
- {
- break;
- }
- else if (instr == GF_CHAR_LOC)
- {
- code = READ_UINT1(fp);
- (void)SKIP_N(fp, 16);
- }
- else if (instr == GF_CHAR_LOC0)
- {
- code = READ_UINT1(fp);
- (void)SKIP_N(fp, 9);
- }
- else
- {
- error = FT_THROW( Invalid_File_Format );
- goto ErrExit;
- }
- if (code < bc)
- bc = code;
- if (code > ec)
- ec = code;
- }
- #else
- bc = 0;
- ec = 255;
- #endif
-
- nchars = ec - bc + 1;
- go= malloc(sizeof(GF_GlyphRec)); /* FT_ALLOC(go, sizeof(GF_GlyphRec)); goto ErrExit; */
- /* Returning unnecessary errors TO BE CHECKED */
-
- 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 */
-
- for (i = 0; i < nchars; i++)
- go->bm_table[i].bitmap = NULL;
-
- go->ds = (double)ds/(1<<20);printf("\ngo->ds is %d\n",go->ds);
- go->hppp = (double)hppp/(1<<16);printf("\ngo->hppp is %d\n",go->hppp);
- go->vppp = (double)vppp/(1<<16);printf("\ngo->vppp is %d\n",go->vppp);
- go->font_bbx_w = max_m - min_m;printf("\ngo->font_bbx_w is %d\n",go->font_bbx_w);
- go->font_bbx_h = max_n - min_n;printf("\ngo->font_bbx_h is %d\n",go->font_bbx_h);
- go->font_bbx_xoff = min_m;printf("\ngo->font_bbx_xoff is %d\n",go->font_bbx_xoff);
- go->font_bbx_yoff = min_n;printf("\ngo->font_bbx_yoff is %d\n",go->font_bbx_yoff);
- go->code_min = bc;printf("\ngo->code_min is %d\n",go->code_min);
- go->code_max = ec;printf("\ngo->code_max is %d\n",go->code_max);
-
- /* read glyph */
- #if 0
- fseek(fp, gptr, SEEK_SET);
- #endif
-
- for ( ; ; )
- {
- if ((instr = READ_UINT1(fp)) == GF_POST_POST)
- break;
- switch ((int)instr)
- {
- case GF_CHAR_LOC:
- code = READ_UINT1(fp);
- dx = (double)READ_INT4(fp)/(double)(1<<16);
- dy = (double)READ_INT4(fp)/(double)(1<<16);
- w = READ_INT4(fp);
- ptr = READ_INT4(fp);
- break;
- case GF_CHAR_LOC0:
- code = READ_UINT1(fp);printf("code is %d\n",code);
- dx = (double)READ_INT1(fp);printf("dx is %d\n",dx);
- dy = (double)0;
- w = READ_INT4(fp);printf("w is %d\n",w);
- ptr = READ_INT4(fp);printf("ptr is %d\n",ptr);
- break;
- default:
- error = FT_THROW( Invalid_File_Format );
- goto ErrExit;
- }
-
- optr = ft_ftell(fp);
- ft_fseek(fp, ptr, SEEK_SET);
-
- bm = &go->bm_table[code - bc];
- if (gf_read_glyph(fp, bm) < 0)
- goto ErrExit;
-
- bm->mv_x = dx;
- bm->mv_y = dy;
- ft_fseek(fp, optr, SEEK_SET);
- }
- *goptr = go;
- tp = ( go->code_max );
- printf("tp go->code_max %d\n",go->code_max);
- printf("\nHi I was here in gf_load_font\n");
-return error;
-
- ErrExit:
- printf("*ERROR\n");
- 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);*/ /* Returning unnecessary errors TO BE CHECKED */
- }
- /* FT_FREE(go); *//* Returning unnecessary errors TO BE CHECKED */
- }
-
-
- FT_LOCAL_DEF( void )
- gf_free_font( GF_Glyph go, FT_Memory memory )
- {
- int i=0, nchars =sizeof(go->bm_table);
- if (go != NULL)
- {
- if (go->bm_table != NULL)
- {
- for (i = 0; i < nchars; i++){}
- /* FT_FREE(go->bm_table[i].bitmap); */ /* To be verified from Vflib */
- }
- /* FT_FREE(go->bm_table); */ /* Returning unnecessary errors TO BE CHECKED */
- }
- /* FT_FREE(go); */ /* Returning unnecessary errors TO BE CHECKED */
- }
-
-
-/* END */