Fri Mar 15 01:35:56 2002 Owen Taylor * pango/opentype/ftxgsub.c pango/opentype/ftxopen.c pango/opentype/ftxopenf.h: In Load_ChainContextSubst2, handle the case where an empty class definition is represented by an offset of 0. * pango/opentype/ftxgpos.c: Same for Load_ChainContextPos2. Index: ftxgpos.c =================================================================== RCS file: /cvs/gnome/pango/pango/opentype/ftxgpos.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -p -r1.3 -r1.4 --- ftxgpos.c 19 Sep 2001 21:20:36 -0000 1.3 +++ ftxgpos.c 15 Mar 2002 06:46:05 -0000 1.4 @@ -4724,6 +4769,30 @@ } + static FT_Error Load_EmptyOrClassDefinition( TTO_ClassDefinition* cd, + FT_UShort limit, + FT_ULong class_offset, + FT_ULong base_offset, + FT_Stream stream ) + { + FT_Error error; + FT_ULong cur_offset; + + cur_offset = FILE_Pos(); + + if ( class_offset ) + { + if ( !FILE_Seek( class_offset + base_offset ) ) + error = Load_ClassDefinition( cd, limit, stream ) == TT_Err_Ok; + } + else + error = Load_EmptyClassDefinition ( cd, stream ); + + (void)FILE_Seek( cur_offset ); + + return error; + } + /* ChainContextPosFormat2 */ static FT_Error Load_ChainContextPos2( TTO_ChainContextPosFormat2* ccpf2, @@ -4768,20 +4837,18 @@ FORGET_Frame(); - cur_offset = FILE_Pos(); - if ( FILE_Seek( backtrack_offset ) || - ( error = Load_ClassDefinition( &ccpf2->BacktrackClassDef, count, - stream ) ) != TT_Err_Ok ) + if ( ( error = Load_EmptyOrClassDefinition( &ccpf2->BacktrackClassDef, count, + backtrack_offset, base_offset, + stream ) ) != TT_Err_Ok ) goto Fail5; - if ( FILE_Seek( input_offset ) || - ( error = Load_ClassDefinition( &ccpf2->InputClassDef, count, - stream ) ) != TT_Err_Ok ) + if ( ( error = Load_EmptyOrClassDefinition( &ccpf2->InputClassDef, count, + input_offset, base_offset, + stream ) ) != TT_Err_Ok ) goto Fail4; - if ( FILE_Seek( lookahead_offset ) || - ( error = Load_ClassDefinition( &ccpf2->LookaheadClassDef, count, - stream ) ) != TT_Err_Ok ) + if ( ( error = Load_EmptyOrClassDefinition( &ccpf2->LookaheadClassDef, count, + lookahead_offset, base_offset, + stream ) ) != TT_Err_Ok ) goto Fail3; - (void)FILE_Seek( cur_offset ); ccpf2->ChainPosClassSet = NULL; ccpf2->MaxBacktrackLength = 0; Index: ftxgsub.c =================================================================== RCS file: /cvs/gnome/pango/pango/opentype/ftxgsub.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -r1.2 -r1.3 --- ftxgsub.c 19 Sep 2001 21:20:36 -0000 1.2 +++ ftxgsub.c 15 Mar 2002 06:46:05 -0000 1.3 @@ -2943,6 +2943,30 @@ } } + static FT_Error Load_EmptyOrClassDefinition( TTO_ClassDefinition* cd, + FT_UShort limit, + FT_ULong class_offset, + FT_ULong base_offset, + FT_Stream stream ) + { + FT_Error error; + FT_ULong cur_offset; + + cur_offset = FILE_Pos(); + + if ( class_offset ) + { + if ( !FILE_Seek( class_offset + base_offset ) ) + error = Load_ClassDefinition( cd, limit, stream ) == TT_Err_Ok; + } + else + error = Load_EmptyClassDefinition ( cd, stream ); + + (void)FILE_Seek( cur_offset ); + + return error; + } + /* ChainContextSubstFormat2 */ @@ -2989,20 +3013,19 @@ FORGET_Frame(); - cur_offset = FILE_Pos(); - if ( FILE_Seek( backtrack_offset ) || - ( error = Load_ClassDefinition( &ccsf2->BacktrackClassDef, count, - stream ) ) != TT_Err_Ok ) - goto Fail5; - if ( FILE_Seek( input_offset ) || - ( error = Load_ClassDefinition( &ccsf2->InputClassDef, count, - stream ) ) != TT_Err_Ok ) - goto Fail4; - if ( FILE_Seek( lookahead_offset ) || - ( error = Load_ClassDefinition( &ccsf2->LookaheadClassDef, count, - stream ) ) != TT_Err_Ok ) + if ( ( error = Load_EmptyOrClassDefinition( &ccsf2->BacktrackClassDef, count, + backtrack_offset, base_offset, + stream ) ) != TT_Err_Ok ) + goto Fail5; + + if ( ( error = Load_EmptyOrClassDefinition( &ccsf2->InputClassDef, count, + input_offset, base_offset, + stream ) ) != TT_Err_Ok ) + goto Fail4; + if ( ( error = Load_EmptyOrClassDefinition( &ccsf2->LookaheadClassDef, count, + lookahead_offset, base_offset, + stream ) ) != TT_Err_Ok ) goto Fail3; - (void)FILE_Seek( cur_offset ); ccsf2->ChainSubClassSet = NULL; ccsf2->MaxBacktrackLength = 0; Index: ftxopen.c =================================================================== RCS file: /cvs/gnome/pango/pango/opentype/ftxopen.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -p -r1.4 -r1.5 --- ftxopen.c 15 Mar 2002 04:22:14 -0000 1.4 +++ ftxopen.c 15 Mar 2002 06:46:05 -0000 1.5 @@ -1199,6 +1199,29 @@ return error; } + + FT_Error Load_EmptyClassDefinition( TTO_ClassDefinition* cd, + FT_Stream stream ) + { + FT_Error error; + FT_Memory memory = stream->memory; + + + if ( ALLOC_ARRAY( cd->Defined, 1, FT_Bool ) ) + return error; + + cd->ClassFormat = 1; /* Meaningless */ + cd->Defined[0] = FALSE; + + if ( ALLOC_ARRAY( cd->cd.cd1.ClassValueArray, 1, FT_UShort ) ) + goto Fail; + + return TT_Err_Ok; + + Fail: + FREE( cd->Defined ); + return error; + } void Free_ClassDefinition( TTO_ClassDefinition* cd, FT_Memory memory ) Index: ftxopenf.h =================================================================== RCS file: /cvs/gnome/pango/pango/opentype/ftxopenf.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -p -r1.1 -r1.2 --- ftxopenf.h 20 Dec 2000 04:41:36 -0000 1.1 +++ ftxopenf.h 15 Mar 2002 06:46:05 -0000 1.2 @@ -39,6 +39,8 @@ extern "C" { FT_Error Load_ClassDefinition( TTO_ClassDefinition* cd, FT_UShort limit, FT_Stream input ); + FT_Error Load_EmptyClassDefinition( TTO_ClassDefinition* cd, + FT_Stream input ); FT_Error Load_Device( TTO_Device* d, FT_Stream input );