diff --git a/config/unix/ftconfig.in b/config/unix/ftconfig.in index c61ab2617..1a91e5b9b 100644 --- a/config/unix/ftconfig.in +++ b/config/unix/ftconfig.in @@ -97,17 +97,17 @@ /* Used to guarantee the size of some specific integers. */ /* */ typedef signed short FT_Int16; - typedef unsigned short FT_Word16; + typedef unsigned short FT_UInt16; #if FT_SIZEOF_INT == 4 typedef signed int FT_Int32; - typedef unsigned int FT_Word32; + typedef unsigned int FT_UInt32; #elif FT_SIZEOF_LONG == 4 typedef signed long FT_Int32; - typedef unsigned long FT_Word32; + typedef unsigned long FT_UInt32; #else #error "no 32bit type found - please check your configuration files" diff --git a/include/freetype/config/ftconfig.h b/include/freetype/config/ftconfig.h index 64506fccd..f6fed4a08 100644 --- a/include/freetype/config/ftconfig.h +++ b/include/freetype/config/ftconfig.h @@ -121,17 +121,17 @@ /* Used to guarantee the size of some specific integers. */ /* */ typedef signed short FT_Int16; - typedef unsigned short FT_Word16; + typedef unsigned short FT_UInt16; #if FT_SIZEOF_INT == 4 typedef signed int FT_Int32; - typedef unsigned int FT_Word32; + typedef unsigned int FT_UInt32; #elif FT_SIZEOF_LONG == 4 typedef signed long FT_Int32; - typedef unsigned long FT_Word32; + typedef unsigned long FT_UInt32; #else #error "no 32bit type found - please check your configuration files" diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index 3c545fc25..e2d060f9d 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -1367,7 +1367,7 @@ /* recognized, or non-zero if not. */ /* */ FT_EXPORT_DEF(FT_Error) FT_New_Memory_Face( FT_Library library, - void* file_base, + FT_Byte* file_base, FT_Long file_size, FT_Long face_index, FT_Face* face ); diff --git a/include/freetype/ftimage.h b/include/freetype/ftimage.h index de9328f23..a1b15c950 100644 --- a/include/freetype/ftimage.h +++ b/include/freetype/ftimage.h @@ -22,6 +22,12 @@ #ifndef FTIMAGE_H #define FTIMAGE_H + +#ifdef __cplusplus + extern "C" { +#endif + + /*************************************************************************/ /* */ /* */ @@ -206,14 +212,14 @@ typedef struct FT_Bitmap_ { - int rows; - int width; - int pitch; - void* buffer; - short num_grays; - char pixel_mode; - char palette_mode; - void* palette; + int rows; + int width; + int pitch; + unsigned char* buffer; + short num_grays; + char pixel_mode; + char palette_mode; + void* palette; } FT_Bitmap; @@ -861,9 +867,9 @@ * **************************************************************************/ - typedef void (*FT_Raster_Reset_Func)( FT_Raster raster, - const char* pool_base, - long pool_size ); + typedef void (*FT_Raster_Reset_Func)( FT_Raster raster, + unsigned char* pool_base, + unsigned long pool_size ); /************************************************************************** @@ -955,5 +961,11 @@ } FT_Raster_Funcs; + +#ifdef __cplusplus + } +#endif + + #endif /* FTIMAGE_H */ diff --git a/include/freetype/ftrender.h b/include/freetype/ftrender.h index 2853927ec..a7ab090b1 100644 --- a/include/freetype/ftrender.h +++ b/include/freetype/ftrender.h @@ -21,6 +21,12 @@ #include #include + +#ifdef __cplusplus + extern "C" { +#endif + + /* create a new glyph object */ typedef FT_Error (*FT_Glyph_Init_Func)( FT_Glyph glyph, FT_GlyphSlot slot ); @@ -177,6 +183,11 @@ +#ifdef __cplusplus + } +#endif + + #endif /* FTMODULE_H */ diff --git a/include/freetype/ftsystem.h b/include/freetype/ftsystem.h index 7e1059b33..8ef12f1af 100644 --- a/include/freetype/ftsystem.h +++ b/include/freetype/ftsystem.h @@ -67,16 +67,16 @@ typedef struct FT_StreamRec_* FT_Stream; - typedef unsigned long (*FT_Stream_IO)( FT_Stream stream, - unsigned long offset, - char* buffer, - unsigned long count ); + typedef unsigned long (*FT_Stream_IO)( FT_Stream stream, + unsigned long offset, + unsigned char* buffer, + unsigned long count ); typedef void (*FT_Stream_Close)( FT_Stream stream ); struct FT_StreamRec_ { - char* base; + unsigned char* base; unsigned long size; unsigned long pos; @@ -87,8 +87,8 @@ FT_Stream_Close close; FT_Memory memory; - char* cursor; - char* limit; + unsigned char* cursor; + unsigned char* limit; }; diff --git a/include/freetype/internal/ftcalc.h b/include/freetype/internal/ftcalc.h index 07900ec08..f9547e4cd 100644 --- a/include/freetype/internal/ftcalc.h +++ b/include/freetype/internal/ftcalc.h @@ -50,8 +50,8 @@ typedef struct FT_Int64_ { - FT_Word32 lo; - FT_Word32 hi; + FT_UInt32 lo; + FT_UInt32 hi; } FT_Int64; diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h index 187596c58..062c709d9 100644 --- a/include/freetype/internal/ftobjs.h +++ b/include/freetype/internal/ftobjs.h @@ -30,6 +30,12 @@ #include #include + +#ifdef __cplusplus + extern "C" { +#endif + + /*************************************************************************/ /* */ /* Some generic definitions. */ @@ -403,8 +409,8 @@ FT_Renderer cur_renderer; /* current outline renderer */ FT_Module auto_hinter; - void* raster_pool; /* scan-line conversion render pool */ - unsigned long raster_pool_size; /* size of render pool in bytes */ + FT_Byte* raster_pool; /* scan-line conversion render pool */ + FT_ULong raster_pool_size; /* size of render pool in bytes */ FT_DebugHook_Func debug_hooks[4]; @@ -441,6 +447,11 @@ #endif +#ifdef __cplusplus + } +#endif + + #endif /* FTOBJS_H */ diff --git a/include/freetype/internal/ftstream.h b/include/freetype/internal/ftstream.h index c8e320f8c..f7dbd3ba0 100644 --- a/include/freetype/internal/ftstream.h +++ b/include/freetype/internal/ftstream.h @@ -3,6 +3,12 @@ #include + +#ifdef __cplusplus + extern "C" { +#endif + + /* format of an 8-bit frame_op value = [ xxxxx | e | s ] */ /* where s is set to 1 when the value is signed.. */ /* where e is set to 1 when the value is little-endian */ @@ -185,27 +191,27 @@ typedef struct FT_Frame_Field_ - BASE_DEF(void) FT_New_Memory_Stream( FT_Library library, - void* base, - unsigned long size, - FT_Stream stream ); + BASE_DEF(void) FT_New_Memory_Stream( FT_Library library, + FT_Byte* base, + FT_ULong size, + FT_Stream stream ); BASE_DEF(FT_Error) FT_Seek_Stream( FT_Stream stream, FT_ULong pos ); BASE_DEF(FT_Error) FT_Skip_Stream( FT_Stream stream, - FT_Long distance ); + FT_Long distance ); BASE_DEF(FT_Long) FT_Stream_Pos( FT_Stream stream ); BASE_DEF(FT_Error) FT_Read_Stream( FT_Stream stream, - void* buffer, + FT_Byte* buffer, FT_ULong count ); BASE_DEF(FT_Error) FT_Read_Stream_At( FT_Stream stream, FT_ULong pos, - void* buffer, + FT_Byte* buffer, FT_ULong count ); BASE_DEF(FT_Error) FT_Access_Frame( FT_Stream stream, @@ -274,18 +280,24 @@ typedef struct FT_Frame_Field_ #define FILE_Pos() \ FT_Stream_Pos( stream ) -#define FILE_Read( buffer, count ) \ - FT_SET_ERROR( FT_Read_Stream( stream, \ - (FT_Char*)buffer, \ +#define FILE_Read( buffer, count ) \ + FT_SET_ERROR( FT_Read_Stream( stream, \ + (FT_Byte*)buffer, \ count ) ) #define FILE_Read_At( position, buffer, count ) \ FT_SET_ERROR( FT_Read_Stream_At( stream, \ position, \ - (FT_Char*)buffer, \ + (FT_Byte*)buffer, \ count ) ) #define READ_Fields( fields, object ) \ ((error = FT_Read_Fields( stream, fields, object )) != FT_Err_Ok) + +#ifdef __cplusplus + } +#endif + + #endif /* FTSTREAM_H */ diff --git a/include/freetype/internal/sfnt.h b/include/freetype/internal/sfnt.h index 5e524bae1..e855dcc5a 100644 --- a/include/freetype/internal/sfnt.h +++ b/include/freetype/internal/sfnt.h @@ -214,11 +214,11 @@ /* TrueType error code. 0 means success. */ /* */ typedef - FT_Error (*TT_Load_Any_Func)( TT_Face face, - FT_ULong tag, - FT_Long offset, - void* buffer, - FT_Long* length ); + FT_Error (*TT_Load_Any_Func)( TT_Face face, + FT_ULong tag, + FT_Long offset, + FT_Byte* buffer, + FT_ULong* length ); /*************************************************************************/ diff --git a/include/freetype/internal/t1types.h b/include/freetype/internal/t1types.h index 974d9764a..a1a2d7b9f 100644 --- a/include/freetype/internal/t1types.h +++ b/include/freetype/internal/t1types.h @@ -24,10 +24,6 @@ #include #include -#ifdef __cplusplus - extern "C" { -#endif - /*************************************************************************/ @@ -190,11 +186,6 @@ } CID_FaceRec; -#ifdef __cplusplus - } -#endif - - #endif /* T1TYPES_H */ diff --git a/include/freetype/internal/t2types.h b/include/freetype/internal/t2types.h index 39608a0fb..0480d45b6 100644 --- a/include/freetype/internal/t2types.h +++ b/include/freetype/internal/t2types.h @@ -27,10 +27,6 @@ #include -#ifdef __cplusplus - extern "C" { -#endif - /************************************************************************* * * @@ -215,9 +211,8 @@ } CFF_Font; -#ifdef __cplusplus - } -#endif #endif /* T2TYPES_H */ + + /* END */ diff --git a/include/freetype/internal/tttypes.h b/include/freetype/internal/tttypes.h index 7b209f40a..8381ded51 100644 --- a/include/freetype/internal/tttypes.h +++ b/include/freetype/internal/tttypes.h @@ -27,11 +27,6 @@ #include -#ifdef __cplusplus - extern "C" { -#endif - - /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ @@ -1506,13 +1501,6 @@ }; - - -#ifdef __cplusplus - } -#endif - - #endif /* TTTYPES_H */ diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c index 55df20c6a..c333c6709 100644 --- a/src/base/ftcalc.c +++ b/src/base/ftcalc.c @@ -223,7 +223,7 @@ FT_Long b ) { FT_Int32 s; - FT_Word32 q; + FT_UInt32 q; s = a; a = ABS(a); @@ -366,7 +366,7 @@ FT_MulTo64( a, b, &temp ); temp2.hi = (FT_Int32)( c >> 31 ); - temp2.lo = (FT_Word32)( c / 2 ); + temp2.lo = (FT_UInt32)( c / 2 ); FT_Add64( &temp, &temp2, &temp ); a = FT_Div64by32( &temp, c ); } @@ -469,7 +469,7 @@ FT_Long b ) { FT_Int32 s; - FT_Word32 q; + FT_UInt32 q; s = a; a = ABS(a); @@ -483,12 +483,12 @@ else if ( ( a >> 16 ) == 0 ) { /* compute result directly */ - q = (FT_Word32)( a << 16 ) / (FT_Word32)b; + q = (FT_UInt32)( a << 16 ) / (FT_UInt32)b; } else { /* we need more bits; we have to do it by hand */ - FT_Word32 c; + FT_UInt32 c; q = ( a / b ) << 16; @@ -531,7 +531,7 @@ FT_Int64* y, FT_Int64* z ) { - register FT_Word32 lo, hi; + register FT_UInt32 lo, hi; lo = x->lo + y->lo; @@ -571,7 +571,7 @@ s ^= y; y = ABS( y ); { - FT_Word32 lo1, hi1, lo2, hi2, lo, hi, i1, i2; + FT_UInt32 lo1, hi1, lo2, hi2, lo, hi, i1, i2; lo1 = x & 0x0000FFFF; hi1 = x >> 16; @@ -600,7 +600,7 @@ if ( s < 0 ) { - z->lo = (FT_Word32)-(FT_Int32)z->lo; + z->lo = (FT_UInt32)-(FT_Int32)z->lo; z->hi = ~z->hi + !( z->lo ); } } @@ -629,13 +629,13 @@ FT_Int32 y ) { FT_Int32 s; - FT_Word32 q, r, i, lo; + FT_UInt32 q, r, i, lo; s = x->hi; if ( s < 0 ) { - x->lo = (FT_Word32)-(FT_Int32)x->lo; + x->lo = (FT_UInt32)-(FT_Int32)x->lo; x->hi = ~x->hi + !( x->lo ); } s ^= y; y = ABS( y ); @@ -654,7 +654,7 @@ r = x->hi; lo = x->lo; - if ( r >= (FT_Word32)y ) /* we know y is to be treated as unsigned here */ + if ( r >= (FT_UInt32)y ) /* we know y is to be treated as unsigned here */ return ( s < 0 ? 0x80000001UL : 0x7FFFFFFFUL ); /* Return Max/Min Int32 if division overflow. */ /* This includes division by zero! */ @@ -665,7 +665,7 @@ q <<= 1; r |= lo >> 31; - if ( r >= (FT_Word32)y ) + if ( r >= (FT_UInt32)y ) { r -= y; q |= 1; @@ -687,7 +687,7 @@ FT_Int64* y, FT_Int64* z ) { - register FT_Word32 lo, hi; + register FT_UInt32 lo, hi; lo = x->lo - y->lo; @@ -701,7 +701,7 @@ static int ft_order64( FT_Int64* z ) { - FT_Word32 i; + FT_UInt32 i; int j; diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 8b6a85760..5ae839e98 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -702,7 +702,7 @@ slot->control_data = 0; slot->control_len = 0; slot->other = 0; - slot->format = 0; + slot->format = ft_glyph_format_none; slot->linearHoriAdvance = 0; slot->linearVertAdvance = 0; @@ -1314,7 +1314,7 @@ /* recognized, or non-zero if not. */ /* */ FT_EXPORT_FUNC( FT_Error ) FT_New_Memory_Face( FT_Library library, - void* file_base, + FT_Byte* file_base, FT_Long file_size, FT_Long face_index, FT_Face* face ) diff --git a/src/base/ftstream.c b/src/base/ftstream.c index 1d8b8b2f3..03413ee02 100644 --- a/src/base/ftstream.c +++ b/src/base/ftstream.c @@ -30,13 +30,13 @@ #define FT_COMPONENT trace_stream - BASE_FUNC( void ) FT_New_Memory_Stream( FT_Library library, - void* base, - unsigned long size, - FT_Stream stream ) + BASE_FUNC( void ) FT_New_Memory_Stream( FT_Library library, + FT_Byte* base, + FT_ULong size, + FT_Stream stream ) { stream->memory = library->memory; - stream->base = (char*)base; + stream->base = base; stream->size = size; stream->pos = 0; stream->cursor = 0; @@ -97,7 +97,7 @@ BASE_FUNC( FT_Error ) FT_Read_Stream( FT_Stream stream, - void* buffer, + FT_Byte* buffer, FT_ULong count ) { return FT_Read_Stream_At( stream, stream->pos, buffer, count ); @@ -106,7 +106,7 @@ BASE_FUNC( FT_Error ) FT_Read_Stream_At( FT_Stream stream, FT_ULong pos, - void* buffer, + FT_Byte* buffer, FT_ULong count ) { FT_Error error = FT_Err_Ok; @@ -285,7 +285,7 @@ BASE_FUNC( FT_Short ) FT_Get_Short( FT_Stream stream ) { - char* p; + FT_Byte* p; FT_Short result; @@ -303,8 +303,8 @@ BASE_FUNC( FT_Long ) FT_Get_Offset( FT_Stream stream ) { - char* p; - FT_Long result; + FT_Byte* p; + FT_Long result; FT_Assert( stream && stream->cursor ); @@ -320,8 +320,8 @@ BASE_FUNC( FT_Long ) FT_Get_Long( FT_Stream stream ) { - char* p; - FT_Long result; + FT_Byte* p; + FT_Long result; FT_Assert( stream && stream->cursor ); @@ -338,7 +338,7 @@ BASE_FUNC( FT_Char ) FT_Read_Char( FT_Stream stream, FT_Error* error ) { - char result = 0; + FT_Byte result = 0; FT_Assert( stream ); @@ -374,8 +374,8 @@ BASE_FUNC( FT_Short ) FT_Read_Short( FT_Stream stream, FT_Error* error ) { - char reads[2]; - char* p = 0; + FT_Byte reads[2]; + FT_Byte* p = 0; FT_Short result = 0; @@ -420,9 +420,9 @@ BASE_FUNC( FT_Long ) FT_Read_Offset( FT_Stream stream, FT_Error* error ) { - char reads[3]; - char* p = 0; - FT_Long result = 0; + FT_Byte reads[3]; + FT_Byte* p = 0; + FT_Long result = 0; FT_Assert( stream ); @@ -466,9 +466,9 @@ BASE_FUNC( FT_Long ) FT_Read_Long( FT_Stream stream, FT_Error* error ) { - char reads[4]; - char* p = 0; - FT_Long result = 0; + FT_Byte reads[4]; + FT_Byte* p = 0; + FT_Long result = 0; FT_Assert( stream ); @@ -543,25 +543,24 @@ case ft_frame_skip: /* skip some bytes */ { FT_Int len = fields->size; - - if (stream->cursor + len > stream->limit) + + + if ( stream->cursor + len > stream->limit ) { error = FT_Err_Invalid_Stream_Operation; goto Exit; } - - if (fields->value == ft_frame_bytes) + + if ( fields->value == ft_frame_bytes ) { p = (FT_Byte*)structure + fields->offset; MEM_Copy( p, stream->cursor, len ); } - stream->cursor += len; + stream->cursor += len; fields++; continue; } - - case ft_frame_byte: case ft_frame_schar: /* read a single byte */ value = GET_Byte(); @@ -577,7 +576,7 @@ case ft_frame_short_le: case ft_frame_ushort_le: /* read a 2-byte little-endian short */ { - char* p; + FT_Byte* p; value = 0; @@ -601,7 +600,7 @@ case ft_frame_long_le: case ft_frame_ulong_le: /* read a 4-byte little-endian long */ { - char* p; + FT_Byte* p; value = 0; @@ -628,7 +627,7 @@ case ft_frame_off3_le: case ft_frame_uoff3_le: /* read a 3-byte little-endian long */ { - char* p; + FT_Byte* p; value = 0; @@ -671,7 +670,7 @@ *(FT_UInt32*)p = (FT_UInt32)value; break; - default: /* for 64-bits systems */ + default: /* for 64-bit systems */ *(FT_ULong*)p = (FT_ULong)value; } diff --git a/src/base/ftsystem.c b/src/base/ftsystem.c index 1132152fc..fc029644b 100644 --- a/src/base/ftsystem.c +++ b/src/base/ftsystem.c @@ -196,10 +196,10 @@ /* The number of bytes actually read. */ /* */ static - unsigned long ft_io_stream( FT_Stream stream, - unsigned long offset, - char* buffer, - unsigned long count ) + unsigned long ft_io_stream( FT_Stream stream, + unsigned long offset, + unsigned char* buffer, + unsigned long count ) { FILE* file; diff --git a/src/cff/t2objs.c b/src/cff/t2objs.c index e274f8ce6..2030bd167 100644 --- a/src/cff/t2objs.c +++ b/src/cff/t2objs.c @@ -159,7 +159,7 @@ void T2_Done_Face( T2_Face face ) { FT_Memory memory = face->root.memory; - SFNT_Interface* sfnt = face->sfnt; + SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt; if ( sfnt ) diff --git a/src/cff/t2parse.c b/src/cff/t2parse.c index 9565765e7..b60f984c1 100644 --- a/src/cff/t2parse.c +++ b/src/cff/t2parse.c @@ -563,6 +563,7 @@ case 1: *(FT_Byte*)q = (FT_Byte)val; break; + case 2: *(FT_Short*)q = (FT_Short)val; break; diff --git a/src/cid/cidafm.h b/src/cid/cidafm.h index 93e8b97a2..1e3f990b7 100644 --- a/src/cid/cidafm.h +++ b/src/cid/cidafm.h @@ -22,6 +22,11 @@ #include +#ifdef __cplusplus + extern "C" { +#endif + + typedef struct CID_Kern_Pair_ { FT_UInt glyph1; @@ -53,6 +58,11 @@ FT_Vector* kerning ); +#ifdef __cplusplus + } +#endif + + #endif /* CIDAFM_H */ diff --git a/src/cid/cidload.c b/src/cid/cidload.c index b9a94f52e..a5957aedc 100644 --- a/src/cid/cidload.c +++ b/src/cid/cidload.c @@ -239,7 +239,7 @@ const CID_Field_Rec t1_field_records[] = { #include - { 0, 0, 0, 0, 0, 0, 0, 0 } + { 0 } }; diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c index d0b241b00..eead86c2f 100644 --- a/src/cid/cidobjs.c +++ b/src/cid/cidobjs.c @@ -194,7 +194,7 @@ } root->style_name = ( *full == ' ' ) ? full + 1 - : "Regular"; + : (char *)"Regular"; } else { diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c index f272bde7a..5b29db401 100644 --- a/src/cid/cidparse.c +++ b/src/cid/cidparse.c @@ -936,7 +936,8 @@ if ( ACCESS_Frame( 31 ) ) goto Exit; - if ( strncmp( stream->cursor, "%!PS-Adobe-3.0 Resource-CIDFont", 31 ) ) + if ( strncmp( (char *)stream->cursor, + "%!PS-Adobe-3.0 Resource-CIDFont", 31 ) ) { FT_TRACE2(( "[not a valid CID-keyed font]\n" )); error = FT_Err_Unknown_File_Format; @@ -950,7 +951,7 @@ buff_len = 256; for (;;) { - FT_Byte *p, *limit = buffer + 256; + FT_Byte *p, *limit = buffer + 256; /* fill input buffer */ buff_len -= 256; diff --git a/src/cid/cidriver.h b/src/cid/cidriver.h index eb1a71be0..a9674eed4 100644 --- a/src/cid/cidriver.h +++ b/src/cid/cidriver.h @@ -19,8 +19,7 @@ #ifndef CIDRIVER_H #define CIDRIVER_H -#include -#include +#include FT_EXPORT_VAR( const FT_Driver_Class ) t1cid_driver_class; diff --git a/src/sfnt/sfobjs.c b/src/sfnt/sfobjs.c index cb3e0f056..87cc0ccec 100644 --- a/src/sfnt/sfobjs.c +++ b/src/sfnt/sfobjs.c @@ -347,7 +347,7 @@ flags |= FT_STYLE_FLAG_ITALIC; } - face->root.style_flags = flags; + root->style_flags = flags; /*********************************************************************/ /* */ @@ -387,17 +387,17 @@ if ( face->num_sbit_strikes ) { - face->root.num_fixed_sizes = face->num_sbit_strikes; - if ( ALLOC_ARRAY( face->root.available_sizes, + root->num_fixed_sizes = face->num_sbit_strikes; + if ( ALLOC_ARRAY( root->available_sizes, face->num_sbit_strikes, FT_Bitmap_Size ) ) return error; for ( n = 0 ; n < face->num_sbit_strikes ; n++ ) { - face->root.available_sizes[n].width = + root->available_sizes[n].width = face->sbit_strikes[n].x_ppem; - face->root.available_sizes[n].height = + root->available_sizes[n].height = face->sbit_strikes[n].y_ppem; } } @@ -464,7 +464,7 @@ void SFNT_Done_Face( TT_Face face ) { FT_Memory memory = face->root.memory; - SFNT_Interface* sfnt = face->sfnt; + SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt; if ( sfnt ) diff --git a/src/sfnt/sfobjs.h b/src/sfnt/sfobjs.h index ac7d34d69..35d92f9d1 100644 --- a/src/sfnt/sfobjs.h +++ b/src/sfnt/sfobjs.h @@ -23,6 +23,11 @@ #include +#ifdef __cplusplus + extern "C" { +#endif + + LOCAL_DEF FT_Error SFNT_Init_Face( FT_Stream stream, TT_Face face, @@ -41,6 +46,11 @@ void SFNT_Done_Face( TT_Face face ); +#ifdef __cplusplus + } +#endif + + #endif /* SFDRIVER_H */ diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c index d838520c7..f15963ead 100644 --- a/src/sfnt/ttcmap.c +++ b/src/sfnt/ttcmap.c @@ -82,8 +82,8 @@ TT_CMap4* cmap4; TT_CMap6* cmap6; - TT_CMap2SubHeader* cmap2sub; - TT_CMap4Segment* segments; + TT_CMap2SubHeader* cmap2sub; + TT_CMap4Segment* segments; if ( cmap->loaded ) @@ -100,7 +100,7 @@ cmap0 = &cmap->c.cmap0; if ( ALLOC( cmap0->glyphIdArray, 256L ) || - FILE_Read( (void*)cmap0->glyphIdArray, 256L ) ) + FILE_Read( cmap0->glyphIdArray, 256L ) ) goto Fail; cmap->get_index = code_to_index0; diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c index 998dca09f..a8557201d 100644 --- a/src/sfnt/ttload.c +++ b/src/sfnt/ttload.c @@ -376,11 +376,11 @@ /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC - FT_Error TT_Load_Any( TT_Face face, - FT_ULong tag, - FT_Long offset, - void* buffer, - FT_Long* length ) + FT_Error TT_Load_Any( TT_Face face, + FT_ULong tag, + FT_Long offset, + FT_Byte* buffer, + FT_ULong* length ) { FT_Error error; FT_Stream stream; @@ -923,7 +923,7 @@ /* allocate the name storage area in memory, then read it */ if ( ALLOC( names->storage, storageSize ) || FILE_Read_At( table_pos + names->storageOffset, - (void*)names->storage, storageSize ) ) + names->storage, storageSize ) ) goto Exit; /* Go through and assign the string pointers to the name records. */ diff --git a/src/sfnt/ttload.h b/src/sfnt/ttload.h index f4d9fa2f0..dd0de6a4f 100644 --- a/src/sfnt/ttload.h +++ b/src/sfnt/ttload.h @@ -52,11 +52,11 @@ SFNT_Header* sfnt ); LOCAL_DEF - FT_Error TT_Load_Any( TT_Face face, - FT_ULong tag, - FT_Long offset, - void* buffer, - FT_Long* length ); + FT_Error TT_Load_Any( TT_Face face, + FT_ULong tag, + FT_Long offset, + FT_Byte* buffer, + FT_ULong* length ); LOCAL_DEF @@ -121,6 +121,11 @@ FT_Stream stream ); +#ifdef __cplusplus + } +#endif + + #endif /* TTLOAD_H */ diff --git a/src/sfnt/ttpost.h b/src/sfnt/ttpost.h index 266f010f2..e3da83606 100644 --- a/src/sfnt/ttpost.h +++ b/src/sfnt/ttpost.h @@ -24,7 +24,7 @@ #include #ifdef __cplusplus -extern "C" { + extern "C" { #endif @@ -42,7 +42,7 @@ extern "C" { #ifdef __cplusplus -} + } #endif diff --git a/src/sfnt/ttsbit.h b/src/sfnt/ttsbit.h index 4c5232ec0..7992a7d1b 100644 --- a/src/sfnt/ttsbit.h +++ b/src/sfnt/ttsbit.h @@ -22,6 +22,11 @@ #include +#ifdef __cplusplus + extern "C" { +#endif + + LOCAL_DEF FT_Error TT_Load_SBit_Strikes( TT_Face face, FT_Stream stream ); @@ -40,6 +45,11 @@ TT_SBit_Metrics* metrics ); +#ifdef __cplusplus + } +#endif + + #endif /* TTSBIT_H */ diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c index 7e3fab30f..198fda2f2 100644 --- a/src/smooth/ftgrays.c +++ b/src/smooth/ftgrays.c @@ -125,7 +125,7 @@ #include "ftgrays.h" -#include /* for FT_UNUSED() */ +#include /* for FT_UNUSED() */ #include /* for FT_TRACE() and FT_ERROR() */ #include /* for FT_Outline_Decompose() */ diff --git a/src/truetype/ttdriver.h b/src/truetype/ttdriver.h index 145d42064..9867fbc30 100644 --- a/src/truetype/ttdriver.h +++ b/src/truetype/ttdriver.h @@ -20,9 +20,6 @@ #define TTDRIVER_H #include -#include -#include -#include FT_EXPORT_VAR( const FT_Driver_Class ) tt_driver_class; diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index ad7c726a4..424d8a413 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -187,7 +187,7 @@ zone->cur = load->outline.points + start_point; zone->tags = (FT_Byte*)load->outline.tags + start_point; zone->contours = (FT_UShort*)load->outline.contours + start_contour; - } + } #undef IS_HINTED @@ -210,14 +210,14 @@ { FT_Error error; FT_Stream stream = loader->stream; - + /* the following line sets the `error' variable through macros! */ (void)( FILE_Seek( offset ) || ACCESS_Frame( byte_count ) ); - + FT_TRACE5(( "Glyph %ld\n", glyph_index )); return error; - } + } static @@ -227,14 +227,14 @@ FORGET_Frame(); - } + } static FT_Error TT_Load_Glyph_Header( TT_Loader* loader ) { FT_Stream stream = loader->stream; - + loader->n_contours = GET_Short(); @@ -248,9 +248,9 @@ loader->bbox.xMax )); FT_TRACE5(( " yMin: %4d yMax: %4d\n", loader->bbox.yMin, loader->bbox.yMax )); - + return FT_Err_Ok; - } + } static @@ -271,11 +271,11 @@ { short* cur = gloader->current.outline.contours; short* limit = cur + n_contours; - + for ( ; cur < limit; cur++ ) cur[0] = GET_UShort(); - + n_points = 0; if ( n_contours > 0 ) n_points = cur[-1] + 1; @@ -283,14 +283,14 @@ error = FT_GlyphLoader_Check_Points( gloader, n_points + 2, 0 ); if ( error ) goto Fail; - + outline = &gloader->current.outline; } /* reading the bytecode instructions */ slot->control_len = 0; slot->control_data = 0; - + n_ins = GET_UShort(); FT_TRACE5(( " Instructions size: %d\n", n_ins )); @@ -317,7 +317,7 @@ { slot->control_len = n_ins; slot->control_data = load->instructions; - + MEM_Copy( load->instructions, stream->cursor, n_ins ); } @@ -407,7 +407,7 @@ outline->n_points = n_points; outline->n_contours = n_contours; - Fail: + Fail: return error; } @@ -433,7 +433,7 @@ error = FT_GlyphLoader_Check_Subglyphs( gloader, num_subglyphs + 1 ); if ( error ) goto Fail; - + subglyph = gloader->current.subglyphs + num_subglyphs; subglyph->arg1 = subglyph->arg2 = 0; @@ -609,7 +609,7 @@ load->exec->glyphIns, n_ins ); if ( error ) goto Exit; - + load->exec->is_composite = FALSE; load->exec->pedantic_hinting = (FT_Bool)( load->load_flags & FT_LOAD_PEDANTIC ); @@ -619,7 +619,7 @@ error = TT_Run_Context( load->exec, debug ); if ( error && load->exec->pedantic_hinting ) goto Exit; - + error = FT_Err_Ok; /* ignore bytecode errors in non-pedantic mode */ } @@ -778,7 +778,7 @@ error = face->read_simple_glyph( loader ); if ( error ) goto Fail; - + #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER { @@ -815,10 +815,11 @@ FT_UInt start_point, start_contour; FT_ULong ins_pos; /* position of composite instructions, if any */ + /* for each subglyph, read composite header */ start_point = gloader->base.outline.n_points; start_contour = gloader->base.outline.n_contours; - + error = face->read_composite_glyph( loader ); if ( error ) goto Fail; @@ -835,11 +836,11 @@ { /* set up remaining glyph fields */ FT_GlyphLoader_Add( gloader ); - + glyph->num_subglyphs = gloader->base.num_subglyphs; glyph->format = ft_glyph_format_composite; glyph->subglyphs = gloader->base.subglyphs; - + goto Exit; } @@ -851,13 +852,13 @@ { FT_Int n, num_base_points, num_new_points; FT_SubGlyph* subglyph = 0; - + FT_UInt num_subglyphs = gloader->current.num_subglyphs; FT_UInt num_base_subgs = gloader->base.num_subglyphs; - + FT_GlyphLoader_Add( gloader ); - + for ( n = 0; n < (FT_Int)num_subglyphs; n++ ) { FT_Vector pp1, pp2; @@ -937,7 +938,7 @@ p1 = gloader->base.outline.points + start_point + k; p2 = gloader->base.outline.points + start_point + l; - + x = p1->x - p2->x; y = p1->y - p2->y; } @@ -1111,7 +1112,7 @@ /* copy outline to our glyph slot */ FT_GlyphLoader_Copy_Points( glyph->loader, loader->gloader ); glyph->outline = glyph->loader->base.outline; - + /* translate array so that (0,0) is the glyph's origin */ FT_Outline_Translate( &glyph->outline, -loader->pp1.x, 0 ); @@ -1394,11 +1395,11 @@ { FT_GlyphLoader* gloader = FT_FACE_DRIVER(face)->glyph_loader; - + loader.gloader = gloader; - + FT_GlyphLoader_Rewind( gloader ); - + tt_prepare_zone( &loader.zone, &gloader->base, 0, 0 ); tt_prepare_zone( &loader.base, &gloader->base, 0, 0 ); } @@ -1436,7 +1437,7 @@ loader.size = (FT_Size)size; loader.glyph = (FT_GlyphSlot)glyph; loader.stream = stream; - + loader.glyf_offset = FILE_Pos(); #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c index d6fd2ed89..2d2e6e043 100644 --- a/src/truetype/ttinterp.c +++ b/src/truetype/ttinterp.c @@ -31,7 +31,7 @@ #define TT_MULFIX FT_MulFix #define TT_MULDIV FT_MulDiv -#define TT_FT_INT64 FT_Int64 +#define TT_INT64 FT_Int64 /*************************************************************************/ @@ -743,7 +743,6 @@ } - LOCAL_FUNC const TT_GraphicsState tt_default_graphics_state = { 0, 0, 0, @@ -850,7 +849,7 @@ static FT_F26Dot6 Norm( FT_F26Dot6 X, FT_F26Dot6 Y ) { - TT_FT_INT64 T1, T2; + TT_INT64 T1, T2; MUL_64( X, X, T1 ); diff --git a/src/truetype/ttinterp.h b/src/truetype/ttinterp.h index 72f022533..cb183606a 100644 --- a/src/truetype/ttinterp.h +++ b/src/truetype/ttinterp.h @@ -216,8 +216,7 @@ } TT_ExecContextRec; - LOCAL_DEF - const TT_GraphicsState tt_default_graphics_state; + extern const TT_GraphicsState tt_default_graphics_state; LOCAL_DEF diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c index c2d35da73..38a80f241 100644 --- a/src/truetype/ttobjs.c +++ b/src/truetype/ttobjs.c @@ -225,7 +225,7 @@ FT_Memory memory = face->root.memory; FT_Stream stream = face->root.stream; - SFNT_Interface* sfnt = face->sfnt; + SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt; /* for `extended TrueType formats' (i.e. compressed versions) */ diff --git a/src/truetype/ttpload.h b/src/truetype/ttpload.h index f731551bf..77802a642 100644 --- a/src/truetype/ttpload.h +++ b/src/truetype/ttpload.h @@ -39,6 +39,12 @@ FT_Error TT_Load_Programs( TT_Face face, FT_Stream stream ); + +#ifdef __cplusplus + } +#endif + + #endif /* TTPLOAD_H */ diff --git a/src/type1/t1afm.c b/src/type1/t1afm.c index 6334d64d1..7cee61176 100644 --- a/src/type1/t1afm.c +++ b/src/type1/t1afm.c @@ -135,7 +135,7 @@ #undef KERN_INDEX -#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 ) +#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 ) /* compare two kerning pairs */ @@ -154,7 +154,7 @@ } - /* parse an AFM file - for now, only read the kerning pairs */ + /* parse an AFM file -- for now, only read the kerning pairs */ LOCAL_FUNC FT_Error T1_Read_AFM( FT_Face t1_face, FT_Stream stream ) @@ -178,7 +178,7 @@ p = start; /* we are now going to count the occurences of `KP' or `KPX' in */ - /* the AFM file. */ + /* the AFM file */ count = 0; for ( p = start; p < limit - 3; p++ ) { @@ -250,7 +250,7 @@ T1_Kern_Pair *min, *mid, *max; FT_ULong index = KERN_INDEX( glyph1, glyph2 ); - + /* simple binary search */ min = afm->kern_pairs; max = min + afm->num_pairs - 1; diff --git a/src/type1/t1afm.h b/src/type1/t1afm.h index 1e9bba0c0..709154ec7 100644 --- a/src/type1/t1afm.h +++ b/src/type1/t1afm.h @@ -22,6 +22,11 @@ #include +#ifdef __cplusplus + extern "C" { +#endif + + typedef struct T1_Kern_Pair_ { FT_UInt glyph1; @@ -30,6 +35,7 @@ } T1_Kern_Pair; + typedef struct T1_AFM_ { FT_Int num_pairs; @@ -53,6 +59,11 @@ FT_Vector* kerning ); +#ifdef __cplusplus + } +#endif + + #endif /* T1AFM_H */ diff --git a/src/type1/t1hinter.c b/src/type1/t1hinter.c index d3b59833e..2b6b6b300 100644 --- a/src/type1/t1hinter.c +++ b/src/type1/t1hinter.c @@ -763,7 +763,6 @@ } - LOCAL_FUNC const T1_Hinter_Funcs t1_hinter_funcs = { (T1_Hinter_ChangeHints)t1_hinter_changehints, diff --git a/src/type1/t1hinter.h b/src/type1/t1hinter.h index db02a53d7..82872e3b3 100644 --- a/src/type1/t1hinter.h +++ b/src/type1/t1hinter.h @@ -225,8 +225,7 @@ /* A table containing the address of various functions used during */ /* the loading of an hinted scaled outline. */ /* */ - LOCAL_DEF - const T1_Hinter_Funcs t1_hinter_funcs; + extern const T1_Hinter_Funcs t1_hinter_funcs; LOCAL_DEF diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c index fe866ac5e..c5ab04c73 100644 --- a/src/type1/t1objs.c +++ b/src/type1/t1objs.c @@ -342,7 +342,8 @@ full++; } - root->style_name = ( *full == ' ' ? full + 1 : "Regular" ); + root->style_name = ( *full == ' ' ? full + 1 + : (char *)"Regular" ); } else { diff --git a/src/type1/t1tokens.c b/src/type1/t1tokens.c index 0b2c63acd..b9d7ca9ac 100644 --- a/src/type1/t1tokens.c +++ b/src/type1/t1tokens.c @@ -459,7 +459,7 @@ FT_UShort tag; FT_ULong size; - FT_Byte* private; + FT_Byte* private_dict; /* are we already in the private dictionary ? */ if ( tokzer->in_private ) @@ -471,8 +471,8 @@ /* made of several segments. We thus first read the number of */ /* segments to compute the total size of the private dictionary */ /* then re-read them into memory. */ - FT_Long start_pos = FILE_Pos(); - FT_ULong private_size = 0; + FT_Long start_pos = FILE_Pos(); + FT_ULong private_dict_size = 0; for (;;) @@ -481,7 +481,7 @@ if ( error || tag != 0x8002 ) break; - private_size += size; + private_dict_size += size; if ( FILE_Skip( size ) ) goto Fail; @@ -489,7 +489,7 @@ /* check that we have a private dictionary there */ /* and allocate private dictionary buffer */ - if ( private_size == 0 ) + if ( private_dict_size == 0 ) { FT_ERROR(( "Open_PrivateDict:" )); FT_ERROR(( " invalid private dictionary section\n" )); @@ -497,14 +497,14 @@ goto Fail; } - if ( ALLOC( private, private_size ) ) + if ( ALLOC( private_dict, private_dict_size ) ) goto Fail; /* read all sections into buffer */ if ( FILE_Seek( start_pos ) ) goto Fail_Private; - private_size = 0; + private_dict_size = 0; for (;;) { error = Read_PFB_Tag( stream, &tag, &size ); @@ -514,10 +514,10 @@ break; } - if ( FILE_Read( private + private_size, size ) ) + if ( FILE_Read( private_dict + private_dict_size, size ) ) goto Fail_Private; - private_size += size; + private_dict_size += size; } /* we must free the field `tokzer.base' if we are in a disk-based */ @@ -525,10 +525,10 @@ if ( stream->read ) FREE( tokzer->base ); - tokzer->base = private; + tokzer->base = private_dict; tokzer->cursor = 0; - tokzer->limit = private_size; - tokzer->max = private_size; + tokzer->limit = private_dict_size; + tokzer->max = private_dict_size; } else { @@ -570,14 +570,14 @@ { size = stream->size - tokzer->cursor - 1; /* remaining bytes */ - if ( ALLOC( private, size ) ) /* allocate private dict buffer */ + if ( ALLOC( private_dict, size ) ) /* alloc private dict buffer */ goto Fail; /* copy eexec-encrypted bytes */ - MEM_Copy( private, tokzer->base + tokzer->cursor + 1, size ); + MEM_Copy( private_dict, tokzer->base + tokzer->cursor + 1, size ); /* reset pointers - forget about file mapping */ - tokzer->base = private; + tokzer->base = private_dict; tokzer->limit = size; tokzer->max = size; tokzer->cursor = 0; @@ -613,10 +613,10 @@ count = stream->size - tokzer->cursor; size = count / 2; - if ( ALLOC( private, size ) ) /* allocate private dict buffer */ + if ( ALLOC( private_dict, size ) ) /* alloc private dict buffer */ goto Fail; - write = private; + write = private_dict; cur = tokzer->base + tokzer->cursor; limit = tokzer->base + tokzer->limit; @@ -664,7 +664,7 @@ FREE( tokzer->base ); /* set up pointers */ - tokzer->base = private; + tokzer->base = private_dict; tokzer->limit = size; tokzer->max = size; tokzer->cursor = 0; @@ -679,7 +679,7 @@ return error; Fail_Private: - FREE( private ); + FREE( private_dict ); goto Fail; } @@ -1004,7 +1004,9 @@ tok->token.len - 1, t1_immediates, imm_max - imm_first_ ); - tok->token.kind2 = ( index >= 0 ) ? imm_first_ + index : 0; + tok->token.kind2 = ( index >= 0 ) + ? (T1_TokenType)( imm_first_ + index ) + : tok_error; break; case tok_any: /* test for keyword */ @@ -1015,14 +1017,14 @@ if ( index >= 0 ) { tok->token.kind = tok_keyword; - tok->token.kind2 = key_first_ + index; + tok->token.kind2 = (T1_TokenType)( key_first_ + index ); } else - tok->token.kind2 = 0; + tok->token.kind2 = tok_error; break; default: - tok->token.kind2 = 0; + tok->token.kind2 = tok_error; } } return tokenizer->error; diff --git a/src/type1/t1tokens.h b/src/type1/t1tokens.h index eeb91bb25..03ae056c8 100644 --- a/src/type1/t1tokens.h +++ b/src/type1/t1tokens.h @@ -21,6 +21,12 @@ #include + +#ifdef __cplusplus + extern "C" { +#endif + + /* enum value of first keyword */ #define key_first_ 100 @@ -232,6 +238,11 @@ FT_Int length, FT_UShort seed ); + +#ifdef __cplusplus + } +#endif + #endif /* T1TOKENS_H */ diff --git a/src/type1z/type1z.c b/src/type1z/type1z.c index a681808b7..03dd82716 100644 --- a/src/type1z/type1z.c +++ b/src/type1z/type1z.c @@ -1,32 +1,21 @@ /***************************************************************************/ /* */ -/* type1.c */ +/* type1z.c */ /* */ -/* FreeType Type 1 driver component */ +/* FreeType experimental Type 1 driver component (body only). */ /* */ -/* Copyright 1996-1998 by */ +/* Copyright 1996-2000 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 */ +/* 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. */ /* */ -/* */ -/* This file is used to compile the FreeType Type 1 font driver. */ -/* It relies on all components included in the "base" layer (see */ -/* the file "ftbase.c"). Source code is located in "freetype/ttlib" */ -/* and contains : */ -/* */ -/* - a driver interface */ -/* - an object manager */ -/* - a table loader */ -/* - a glyph loader */ -/* - a glyph hinter */ -/* */ /***************************************************************************/ + #define FT_MAKE_OPTION_SINGLE_OBJECT #include @@ -39,3 +28,5 @@ #include #endif + +/* END */ diff --git a/src/type1z/z1afm.c b/src/type1z/z1afm.c index 4651c2109..c75809993 100644 --- a/src/type1z/z1afm.c +++ b/src/type1z/z1afm.c @@ -1,51 +1,86 @@ -/*************************************************************************** - * - * t1afm.c - support for reading Type 1 AFM files - * - * - ***************************************************************************/ +/***************************************************************************/ +/* */ +/* z1afm.c */ +/* */ +/* AFM support for Type 1 fonts (body). */ +/* */ +/* Copyright 1996-2000 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 #include #include -#include /* for qsort */ + +#include /* for qsort() */ +#include /* for strcmp() */ +#include /* for isalnum() */ + + + /*************************************************************************/ + /* */ + /* 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_z1afm + LOCAL_FUNC - void Z1_Done_AFM( FT_Memory memory, Z1_AFM* afm ) + void Z1_Done_AFM( FT_Memory memory, + Z1_AFM* afm ) { FREE( afm->kern_pairs ); afm->num_pairs = 0; } + #undef IS_KERN_PAIR -#define IS_KERN_PAIR(p) ( p[0] == 'K' && p[1] == 'P' ) +#define IS_KERN_PAIR( p ) ( p[0] == 'K' && p[1] == 'P' ) -#define IS_ALPHANUM(c) ( (c >= 'A' && c <= 'Z') || \ - (c >= 'a' && c <= 'z') || \ - (c >= '0' && c <= '9') || \ - (c == '_' && c == '.') ) +#define IS_ALPHANUM( c ) ( isalnum( c ) || \ + c == '_' || \ + c == '.' ) - /* read a glyph name and return the equivalent glyph index */ + + /* read a glyph name and return the equivalent glyph index */ static - FT_UInt afm_atoindex( FT_Byte* *start, FT_Byte* limit, T1_Font* type1 ) + FT_UInt afm_atoindex( FT_Byte** start, + FT_Byte* limit, + T1_Font* type1 ) { - FT_Byte* p = *start; - FT_Int len; - FT_UInt result = 0; - char temp[64]; + FT_Byte* p = *start; + FT_Int len; + FT_UInt result = 0; + char temp[64]; + /* skip whitespace */ - while ( (*p == ' ' || *p == '\t' || *p == ':' || *p == ';') && p < limit ) + while ( ( *p == ' ' || *p == '\t' || *p == ':' || *p == ';' ) && + p < limit ) p++; *start = p; /* now, read glyph name */ - while ( IS_ALPHANUM(*p) && p < limit ) p++; + while ( IS_ALPHANUM( *p ) && p < limit ) + p++; + len = p - *start; - if (len > 0 && len < 64) + + if ( len > 0 && len < 64 ) { FT_Int n; + /* copy glyph name to intermediate array */ MEM_Copy( temp, *start, len ); temp[len] = 0; @@ -55,7 +90,8 @@ { char* gname = (char*)type1->glyph_names[n]; - if ( gname && gname[0] == temp[0] && strcmp(gname,temp) == 0 ) + + if ( gname && gname[0] == temp[0] && strcmp( gname, temp ) == 0 ) { result = n; break; @@ -67,56 +103,61 @@ } - /* read an integer */ + /* read an integer */ static - int afm_atoi( FT_Byte** start, FT_Byte* limit ) + int afm_atoi( FT_Byte** start, + FT_Byte* limit ) { FT_Byte* p = *start; int sum = 0; int sign = 1; + /* skip everything that is not a number */ - while ( p < limit && (*p < '0' || *p > '9') ) + while ( p < limit && !isdigit( *p ) ) { sign = 1; - if (*p == '-') + if ( *p == '-' ) sign = -1; p++; } - while ( p < limit && (*p >= '0' && *p < '9') ) + while ( p < limit && isdigit( *p ) ) { - sum = sum*10 + (*p - '0'); + sum = sum * 10 + ( *p - '0' ); p++; } *start = p; - return sum*sign; + + return sum * sign; } #undef KERN_INDEX -#define KERN_INDEX(g1,g2) (((FT_ULong)g1 << 16) | g2) +#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 ) - /* compare two kerning pairs */ + + /* compare two kerning pairs */ static - int compare_kern_pairs( const void* a, const void* b ) + int compare_kern_pairs( const void* a, + const void* b ) { Z1_Kern_Pair* pair1 = (Z1_Kern_Pair*)a; Z1_Kern_Pair* pair2 = (Z1_Kern_Pair*)b; - FT_ULong index1 = KERN_INDEX(pair1->glyph1,pair1->glyph2); - FT_ULong index2 = KERN_INDEX(pair2->glyph1,pair2->glyph2); + FT_ULong index1 = KERN_INDEX( pair1->glyph1, pair1->glyph2 ); + FT_ULong index2 = KERN_INDEX( pair2->glyph1, pair2->glyph2 ); - return ( index1 < index2 ? -1 : - ( index1 > index2 ? 1 : 0 )); + + return ( index1 - index2 ); } - /* parse an AFM file - for now, only read the kerning pairs */ + /* parse an AFM file -- for now, only read the kerning pairs */ LOCAL_FUNC - FT_Error Z1_Read_AFM( FT_Face t1_face, - FT_Stream stream ) + FT_Error Z1_Read_AFM( FT_Face t1_face, + FT_Stream stream ) { FT_Error error; FT_Memory memory = stream->memory; @@ -128,28 +169,29 @@ T1_Font* type1 = &((T1_Face)t1_face)->type1; Z1_AFM* afm = 0; - if ( ACCESS_Frame(stream->size) ) + + if ( ACCESS_Frame( stream->size ) ) return error; start = (FT_Byte*)stream->cursor; limit = (FT_Byte*)stream->limit; p = start; - /* we are now going to count the occurences of "KP" or "KPX" in */ - /* the AFM file.. */ + /* we are now going to count the occurences of `KP' or `KPX' in */ + /* the AFM file */ count = 0; - for ( p = start; p < limit-3; p++ ) + for ( p = start; p < limit - 3; p++ ) { - if ( IS_KERN_PAIR(p) ) + if ( IS_KERN_PAIR( p ) ) count++; } - /* Actually, kerning pairs are simply optional !! */ - if (count == 0) + /* Actually, kerning pairs are simply optional! */ + if ( count == 0 ) goto Exit; /* allocate the pairs */ - if ( ALLOC( afm, sizeof(*afm ) ) || + if ( ALLOC( afm, sizeof ( *afm ) ) || ALLOC_ARRAY( afm->kern_pairs, count, Z1_Kern_Pair ) ) goto Exit; @@ -160,15 +202,17 @@ /* save in face object */ ((T1_Face)t1_face)->afm_data = afm; - for ( p = start; p < limit-3; p++ ) + for ( p = start; p < limit - 3; p++ ) { - if ( IS_KERN_PAIR(p) ) + if ( IS_KERN_PAIR( p ) ) { FT_Byte* q; + /* skip keyword (KP or KPX) */ - q = p+2; - if (*q == 'X') q++; + q = p + 2; + if ( *q == 'X' ) + q++; pair->glyph1 = afm_atoindex( &q, limit, type1 ); pair->glyph2 = afm_atoindex( &q, limit, type1 ); @@ -183,18 +227,20 @@ } /* now, sort the kern pairs according to their glyph indices */ - qsort( afm->kern_pairs, count, sizeof(Z1_Kern_Pair), compare_kern_pairs ); + qsort( afm->kern_pairs, count, sizeof ( Z1_Kern_Pair ), + compare_kern_pairs ); Exit: - if (error) + if ( error ) FREE( afm ); FORGET_Frame(); + return error; } - /* find the kerning for a given glyph pair */ + /* find the kerning for a given glyph pair */ LOCAL_FUNC void Z1_Get_Kerning( Z1_AFM* afm, FT_UInt glyph1, @@ -202,28 +248,36 @@ FT_Vector* kerning ) { Z1_Kern_Pair *min, *mid, *max; - FT_ULong index = KERN_INDEX(glyph1,glyph2); + FT_ULong index = KERN_INDEX( glyph1, glyph2 ); + /* simple binary search */ min = afm->kern_pairs; - max = min + afm->num_pairs-1; + max = min + afm->num_pairs - 1; - while (min <= max) + while ( min <= max ) { FT_ULong midi; - mid = min + (max-min)/2; - midi = KERN_INDEX(mid->glyph1,mid->glyph2); + + mid = min + ( max - min ) / 2; + midi = KERN_INDEX( mid->glyph1, mid->glyph2 ); + if ( midi == index ) { *kerning = mid->kerning; return; } - if ( midi < index ) min = mid+1; - else max = mid-1; + if ( midi < index ) + min = mid + 1; + else + max = mid - 1; } + kerning->x = 0; kerning->y = 0; } + +/* END */ diff --git a/src/type1z/z1afm.h b/src/type1z/z1afm.h index eb48e1268..4b95393fe 100644 --- a/src/type1z/z1afm.h +++ b/src/type1z/z1afm.h @@ -1,50 +1,70 @@ -/*************************************************************************** - * - * t1afm.h - support for reading Type 1 AFM files - * - * - ***************************************************************************/ - -#ifndef T1AFM_H -#define T1AFM_H - -#include -#include -#include -#include - -/* In this version, we only read the kerning table from the */ -/* AFM file. We may add support for ligatures a bit later.. */ - -typedef struct Z1_Kern_Pair_ -{ - FT_UInt glyph1; - FT_UInt glyph2; - FT_Vector kerning; - -} Z1_Kern_Pair; +/***************************************************************************/ +/* */ +/* z1afm.h */ +/* */ +/* AFM support for Type 1 fonts (specification). */ +/* */ +/* Copyright 1996-2000 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. */ +/* */ +/***************************************************************************/ -typedef struct Z1_AFM_ -{ - FT_Int num_pairs; - Z1_Kern_Pair* kern_pairs; +#ifndef Z1AFM_H +#define Z1AFM_H -} Z1_AFM; +#include -LOCAL_DEF -FT_Error Z1_Read_AFM( FT_Face face, - FT_Stream stream ); +#ifdef __cplusplus + extern "C" { +#endif -LOCAL_DEF -void Z1_Done_AFM( FT_Memory memory, - Z1_AFM* afm ); -LOCAL_DEF -void Z1_Get_Kerning( Z1_AFM* afm, - FT_UInt glyph1, - FT_UInt glyph2, - FT_Vector* kerning ); + typedef struct Z1_Kern_Pair_ + { + FT_UInt glyph1; + FT_UInt glyph2; + FT_Vector kerning; -#endif /* T1AFM_H */ + } Z1_Kern_Pair; + + + typedef struct Z1_AFM_ + { + FT_Int num_pairs; + Z1_Kern_Pair* kern_pairs; + + } Z1_AFM; + + + LOCAL_DEF + FT_Error Z1_Read_AFM( FT_Face face, + FT_Stream stream ); + + LOCAL_DEF + void Z1_Done_AFM( FT_Memory memory, + Z1_AFM* afm ); + + LOCAL_DEF + void Z1_Get_Kerning( Z1_AFM* afm, + FT_UInt glyph1, + FT_UInt glyph2, + FT_Vector* kerning ); + + +#ifdef __cplusplus + } +#endif + + +#endif /* Z1AFM_H */ + + +/* END */ diff --git a/src/type1z/z1driver.h b/src/type1z/z1driver.h index 6c8c92b46..542a8904a 100644 --- a/src/type1z/z1driver.h +++ b/src/type1z/z1driver.h @@ -15,12 +15,12 @@ * ******************************************************************/ -#ifndef T1DRIVER_H -#define T1DRIVER_H +#ifndef Z1DRIVER_H +#define Z1DRIVER_H #include FT_EXPORT_VAR(const FT_Driver_Class) t1z_driver_class; -#endif /* T1DRIVER_H */ +#endif /* Z1DRIVER_H */ diff --git a/src/type1z/z1gload.h b/src/type1z/z1gload.h index 4140792da..58986023b 100644 --- a/src/type1z/z1gload.h +++ b/src/type1z/z1gload.h @@ -32,8 +32,8 @@ * ******************************************************************/ -#ifndef T1GLOAD_H -#define T1GLOAD_H +#ifndef Z1GLOAD_H +#define Z1GLOAD_H #include @@ -185,4 +185,4 @@ } #endif -#endif /* T1GLOAD_H */ +#endif /* Z1GLOAD_H */ diff --git a/src/type1z/z1load.h b/src/type1z/z1load.h index bf2333cf5..cedb44db7 100644 --- a/src/type1z/z1load.h +++ b/src/type1z/z1load.h @@ -15,8 +15,8 @@ * ******************************************************************/ -#ifndef T1LOAD_H -#define T1LOAD_H +#ifndef Z1LOAD_H +#define Z1LOAD_H #include #include @@ -71,7 +71,7 @@ } #endif -#endif /* T1LOAD_H */ +#endif /* Z1LOAD_H */ /* END */ diff --git a/src/type1z/z1objs.c b/src/type1z/z1objs.c index 5acaadbef..054dbcc8d 100644 --- a/src/type1z/z1objs.c +++ b/src/type1z/z1objs.c @@ -201,7 +201,8 @@ full++; } - root->style_name = ( *full == ' ' ? full+1 : "Regular" ); + root->style_name = ( *full == ' ' ? full + 1 + : (char *)"Regular" ); } else { diff --git a/src/type1z/z1objs.h b/src/type1z/z1objs.h index 6d555ebd9..6d6b3d46f 100644 --- a/src/type1z/z1objs.h +++ b/src/type1z/z1objs.h @@ -15,8 +15,8 @@ * ******************************************************************/ -#ifndef T1OBJS_H -#define T1OBJS_H +#ifndef Z1OBJS_H +#define Z1OBJS_H #include #include @@ -209,7 +209,7 @@ } #endif -#endif /* T1OBJS_H */ +#endif /* Z1OBJS_H */ /* END */ diff --git a/src/type1z/z1parse.h b/src/type1z/z1parse.h index d0d1b87f4..975c7c61d 100644 --- a/src/type1z/z1parse.h +++ b/src/type1z/z1parse.h @@ -28,8 +28,8 @@ * ******************************************************************/ -#ifndef T1PARSE_H -#define T1PARSE_H +#ifndef Z1PARSE_H +#define Z1PARSE_H #include @@ -341,7 +341,7 @@ } #endif -#endif /* T1PARSE_H */ +#endif /* Z1PARSE_H */ /* END */