diff --git a/src/gxlayout/gxload.c b/src/gxlayout/gxload.c index 85ffc685a..54322b906 100644 --- a/src/gxlayout/gxload.c +++ b/src/gxlayout/gxload.c @@ -103,7 +103,7 @@ typedef struct generic_lookup_table_cb_data_rec_ property values, one for each glyph in the segment. " If not "the value of each lookupSingle is a 16-bit offset from the start of the table " specified by TABLE_TAG. */ - FT_Int table_tag; + FT_Int table_tag; FT_Pointer extra; } generic_lookup_table_cb_data_rec, *generic_lookup_table_cb_data; @@ -129,9 +129,9 @@ typedef struct generic_state_table_cb_data_rec_ FT_Stream stream; GX_Face face; FT_Pointer extra; -} generic_state_table_cb_data_rec, +} generic_state_table_cb_data_rec, generic_xstate_table_cb_data_rec, - *generic_state_table_cb_data, + *generic_state_table_cb_data, *generic_xstate_table_cb_data; static FT_Error @@ -151,8 +151,8 @@ generic_triple_offset_diff ( FT_ULong ligActionTable_offset, FT_UShort *ligatureTable_nLigature ); static FT_Error -gx_table_init(GX_Table table_info, - GX_Face face, +gx_table_init(GX_Table table_info, + GX_Face face, FT_ULong tag, FT_Stream stream, GX_Table_Done_Func done_table); @@ -182,7 +182,7 @@ gx_table_init(GX_Table table_info, static void gx_trak_done_values ( FT_Memory memory, - FT_UShort nTracks, + FT_UShort nTracks, GX_TrackTableEntry trackTable ); static void @@ -198,16 +198,16 @@ gx_table_init(GX_Table table_info, FT_Memory memory = stream->memory; FT_FWord * base_value; FT_ULong table_offset; - + if ( FT_NEW_ARRAY ( base_value, nTracks * nSizes ) ) return error; /* assert -> nTracks != 0, nSizes != 0 */ - + if ( ( error = face->goto_table( face, TTAG_trak, stream, 0 ) ) ) return error; table_offset = FT_STREAM_POS(); - + for ( i = 0; i < nTracks; i++ ) { trackTable[i].tracking_value = base_value + (i * nSizes); @@ -228,7 +228,7 @@ gx_table_init(GX_Table table_info, static void gx_trak_done_values ( FT_Memory memory, - FT_UShort nTracks, + FT_UShort nTracks, GX_TrackTableEntry trackTable ) { FT_Int i; @@ -246,8 +246,8 @@ gx_table_init(GX_Table table_info, FT_Int i; FT_Error error; FT_Memory memory = stream->memory; - - const FT_Frame_Field track_table_entry_fields [] = + + static const FT_Frame_Field track_table_entry_fields [] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_TrackTableEntryRec @@ -257,14 +257,14 @@ gx_table_init(GX_Table table_info, FT_FRAME_USHORT (offset), FT_FRAME_END }; - + if ( FT_NEW_ARRAY( *table_entry, nTracks ) ) return error; - + for ( i = 0; i < nTracks ; i++ ) { (*table_entry)[i].tracking_value = NULL; - if ( FT_STREAM_READ_FIELDS( track_table_entry_fields, + if ( FT_STREAM_READ_FIELDS( track_table_entry_fields, &(*table_entry)[i] ) ) goto Failure; } @@ -284,9 +284,9 @@ gx_table_init(GX_Table table_info, { FT_Int i; FT_Error error; - FT_Memory memory = stream->memory; - - if ( (error = face->goto_table( face, TTAG_trak, stream, 0 )) || + FT_Memory memory = stream->memory; + + if ( (error = face->goto_table( face, TTAG_trak, stream, 0 )) || FT_STREAM_SKIP( sizeTableOffset ) ) goto Exit; @@ -294,7 +294,7 @@ gx_table_init(GX_Table table_info, if ( FT_NEW_ARRAY( *sizeTable, nSizes ) ) goto Exit; - + if ( FT_FRAME_ENTER ( sizeof( **sizeTable ) * nSizes ) ) goto Failure; for ( i = 0; i < nSizes; i++) @@ -317,7 +317,7 @@ gx_table_init(GX_Table table_info, FT_Error error; FT_Memory memory = stream->memory; - const FT_Frame_Field track_data_fields [] = + static const FT_Frame_Field track_data_fields [] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_TrackDataRec @@ -332,7 +332,7 @@ gx_table_init(GX_Table table_info, FT_STREAM_SKIP( offset ) || FT_STREAM_READ_FIELDS( track_data_fields, data ) ) goto Exit; - + if ( data->nTracks < 3 ) { FT_TRACE2(( " Too few nTracks in kern\n" )); @@ -345,17 +345,17 @@ gx_table_init(GX_Table table_info, error = GX_Err_Invalid_File_Format; goto Exit; } - - if ( ( error = gx_face_load_trak_table_entry ( face, stream, + + if ( ( error = gx_face_load_trak_table_entry ( face, stream, data->nTracks, - &data->trackTable ) )) + &data->trackTable ) )) goto Exit; - - if ( ( error = gx_face_load_trak_values ( face, stream, + + if ( ( error = gx_face_load_trak_values ( face, stream, data->nTracks, data->nSizes, data->trackTable ) ) ) goto Failure; - + if ( ( error = gx_face_load_trak_size_table ( face, stream, data->nSizes, @@ -366,7 +366,7 @@ gx_table_init(GX_Table table_info, gx_trak_done_values( memory, data->nTracks, data->trackTable); goto Failure; } - + Exit: return error; Failure: @@ -393,8 +393,8 @@ gx_table_init(GX_Table table_info, { FT_Error error; FT_Memory memory = stream->memory; - - const FT_Frame_Field trak_fields[] = + + static const FT_Frame_Field trak_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_TrakRec @@ -406,24 +406,24 @@ gx_table_init(GX_Table table_info, FT_FRAME_USHORT ( reserved ), FT_FRAME_END }; - + if (( error = gx_table_init( &(trak->root), face, TTAG_trak, stream, (GX_Table_Done_Func)gx_trak_done) )) goto Exit; - + if ( FT_STREAM_READ_FIELDS( trak_fields, trak ) ) goto Exit; if ( trak->horizOffset && - ( error = gx_face_load_trak_data (face, stream, - trak->horizOffset, + ( error = gx_face_load_trak_data (face, stream, + trak->horizOffset, &trak->horizData) )) goto Exit; - - if ( trak->vertOffset && - ( error = gx_face_load_trak_data (face, stream, - trak->vertOffset, + + if ( trak->vertOffset && + ( error = gx_face_load_trak_data (face, stream, + trak->vertOffset, &trak->vertData) )) goto Failure; /* FT_TRACE2(( "loaded\n" )); */ @@ -457,7 +457,7 @@ gx_table_init(GX_Table table_info, FT_Error error; FT_Int i; - const FT_Frame_Field feature_settingName_fields [] = + static const FT_Frame_Field feature_settingName_fields [] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_FeatureSettingNameRec @@ -466,12 +466,12 @@ gx_table_init(GX_Table table_info, FT_FRAME_SHORT (nameIndex), FT_FRAME_END }; - + error = face->goto_table( face, TTAG_feat, stream, 0 ); if ( error || FT_STREAM_SKIP( settingTable ) ) goto Exit; - + for ( i = 0; i < nSettings; i++ ) if ( FT_STREAM_READ_FIELDS( feature_settingName_fields, &(settingName[i]) )) @@ -492,10 +492,10 @@ gx_table_init(GX_Table table_info, GX_FeatureSettingName settingName; FT_Int i; - const FT_Frame_Field feature_name_fields [] = + static const FT_Frame_Field feature_name_fields [] = { #undef FT_STRUCTURE -#define FT_STRUCTURE GX_FeatureNameRec +#define FT_STRUCTURE GX_FeatureNameRec FT_FRAME_START ( 12 ), FT_FRAME_USHORT ( feature ), FT_FRAME_USHORT ( nSettings ), @@ -504,7 +504,7 @@ gx_table_init(GX_Table table_info, FT_FRAME_SHORT ( nameIndex ), FT_FRAME_END }; - + for ( i = 0, total_nSettings = 0; i < featureNameCount; i++ ) { if ( FT_STREAM_READ_FIELDS( feature_name_fields, &(names[i]) ) ) @@ -512,10 +512,10 @@ gx_table_init(GX_Table table_info, total_nSettings += names[i].nSettings; } - + if ( FT_NEW_ARRAY ( settingName, total_nSettings ) ) return error; - + for ( i = 0, offset = 0; i < featureNameCount; i++ ) { names[i].settingName = settingName + offset; @@ -524,10 +524,10 @@ gx_table_init(GX_Table table_info, for ( i = 0; i < featureNameCount; i++ ) { - error = gx_face_load_feat_settingName(face, + error = gx_face_load_feat_settingName(face, stream, names[i].settingTable, - names[i].nSettings, + names[i].nSettings, names[i].settingName); if ( error ) { @@ -539,7 +539,7 @@ gx_table_init(GX_Table table_info, } return error; } - + static void gx_feat_done_names( FT_Memory memory, FT_UShort featureNameCount, @@ -547,7 +547,7 @@ gx_table_init(GX_Table table_info, { GX_FeatureSettingName settingName; FT_Int i; - + settingName = names[0].settingName; for ( i = 0; i < featureNameCount; i++ ) names[i].settingName = NULL; @@ -561,8 +561,8 @@ gx_table_init(GX_Table table_info, { FT_Error error; FT_Memory memory = stream->memory; - - const FT_Frame_Field feat_fields[] = + + static const FT_Frame_Field feat_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_FeatRec @@ -573,12 +573,12 @@ gx_table_init(GX_Table table_info, FT_FRAME_ULONG ( reserved2 ), FT_FRAME_END }; - + /* FT_TRACE2(( "Feature " )); */ if (( error = gx_table_init( &(feat->root), face, TTAG_feat, stream, (GX_Table_Done_Func) gx_feat_done) )) goto Exit; - + if ( FT_STREAM_READ_FIELDS( feat_fields, feat ) ) goto Exit; /* err? */ @@ -590,11 +590,11 @@ gx_table_init(GX_Table table_info, feat->names = NULL; goto Exit; } - + if ( FT_NEW_ARRAY( feat->names, feat->featureNameCount ) ) goto Exit; - error = gx_face_load_feat_names ( face, stream, + error = gx_face_load_feat_names ( face, stream, feat->featureNameCount, feat->names ); if ( error ) @@ -611,10 +611,10 @@ gx_table_init(GX_Table table_info, FT_LOCAL_DEF ( void ) gx_feat_done( GX_Feat feat, FT_Memory memory ) - + { GX_FeatureName names; - + names = feat->names; if ( feat->names ) { @@ -633,7 +633,7 @@ gx_table_init(GX_Table table_info, FT_Error error; GX_LookupTable lookup_table = &prop->lookup_data; - const FT_Frame_Field prop_fields[] = + static const FT_Frame_Field prop_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_PropRec @@ -653,7 +653,7 @@ gx_table_init(GX_Table table_info, user_data.lookup_table = lookup_table; user_data.table_tag = 0; /* FT_TRACE2(( "Glyph Properties " )); */ - + if (( error = gx_table_init( &(prop->root), face, TTAG_prop, stream, (GX_Table_Done_Func)gx_prop_done) )) goto Exit; @@ -669,13 +669,13 @@ gx_table_init(GX_Table table_info, lookup_table->fsHeader.any = 0; goto Exit; } - + if (( error = gx_face_load_LookupTable ( face, stream, lookup_table ))) goto Exit; if ( lookup_table->format == GX_LOOKUPTABLE_SEGMENT_ARRAY ) { - if (( error = gx_LookupTable_traverse_low( lookup_table, - &funcs, + if (( error = gx_LookupTable_traverse_low( lookup_table, + &funcs, &user_data ) )) goto Failure; } @@ -689,7 +689,7 @@ gx_table_init(GX_Table table_info, FT_LOCAL_DEF( void ) gx_prop_done( GX_Prop prop, FT_Memory memory ) - + { GX_LookupTable lookup_table = &prop->lookup_data; GX_LookupTable_FuncsRec funcs = GX_LOOKUP_TABLE_FUNC_ZERO; @@ -704,19 +704,19 @@ gx_table_init(GX_Table table_info, memory ); gx_LookupTable_free ( lookup_table, memory ); } - } + } /******************************OPBD************************************/ static FT_Error - gx_opbd_load_data ( GX_Face face, + gx_opbd_load_data ( GX_Face face, FT_Stream stream, FT_ULong offset, FT_UShort format, GX_OpticalBoundsData data ) { FT_Error error; - const FT_Frame_Field opbd_distance_fields[] = + static const FT_Frame_Field opbd_distance_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_OpticalBoundsDataRec @@ -727,7 +727,7 @@ gx_table_init(GX_Table table_info, FT_FRAME_SHORT (distance.bottom_side), FT_FRAME_END }; - const FT_Frame_Field opbd_control_points_fields[] = + static const FT_Frame_Field opbd_control_points_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_OpticalBoundsDataRec @@ -741,7 +741,7 @@ gx_table_init(GX_Table table_info, if ( FT_STREAM_SEEK(offset) ) return error; - + if ( format == GX_OPBD_DISTANCE ) { if ( FT_STREAM_READ_FIELDS( opbd_distance_fields, data ) ) @@ -755,7 +755,7 @@ gx_table_init(GX_Table table_info, return error; } - static FT_Error + static FT_Error opbd_lookup_table_generic_loader( GX_LookupTable_Format format, GX_LookupValue value, FT_Pointer user ) @@ -768,16 +768,16 @@ gx_table_init(GX_Table table_info, FT_Memory memory = stream->memory; FT_Short offset = value->raw.s; GX_OpticalBoundsData opbd_data; - + if ( ( error = face->goto_table(face, TTAG_opbd, stream, 0 ) ) ) return error; - + if ( FT_MEM_NEW(opbd_data) ) return error; - + if ( ( error = gx_opbd_load_data( face, stream, - FT_STREAM_POS() + offset, + FT_STREAM_POS() + offset, data_format, opbd_data ) ) ) goto Failure; @@ -787,7 +787,7 @@ gx_table_init(GX_Table table_info, FT_FREE(opbd_data); return error; } - + static FT_Error opbd_lookup_table_segment_array_loader ( GX_LookupTable_Format format, FT_UShort lastGlyph, @@ -797,7 +797,7 @@ gx_table_init(GX_Table table_info, { FT_Error error; FT_UShort segment_count = lastGlyph - firstGlyph + 1; - + GX_Face face = ((generic_lookup_table_cb_data)user)->face; FT_Pointer extra = ((generic_lookup_table_cb_data)user)->extra; FT_UShort data_format = *(FT_UShort*)extra; @@ -805,20 +805,20 @@ gx_table_init(GX_Table table_info, FT_Memory memory = stream->memory; FT_Short offset = value->raw.s; GX_OpticalBoundsData opbd_data; - + FT_ULong base_offset; FT_Int opbd_data_advance = 4 * sizeof(FT_Short); FT_Int i; - + /* Offset from the start of opbd table (written in spec) */ if ( ( error = face->goto_table(face, TTAG_opbd, stream, 0 ) ) ) goto Exit; - + if ( ( FT_NEW_ARRAY ( opbd_data, segment_count ) ) ) goto Exit; - + base_offset = FT_STREAM_POS() + offset; - + for ( i = 0; i < segment_count; i++ ) { if ( ( error = gx_opbd_load_data( face, @@ -842,7 +842,7 @@ gx_table_init(GX_Table table_info, GX_Opbd opbd ) { FT_Error error; - const FT_Frame_Field opbd_fields[] = + static const FT_Frame_Field opbd_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_OpbdRec @@ -863,13 +863,13 @@ gx_table_init(GX_Table table_info, if (( error = gx_table_init( &(opbd->root), face, TTAG_opbd, stream, (GX_Table_Done_Func)gx_opbd_done) )) goto Exit; - + if ( FT_STREAM_READ_FIELDS( opbd_fields, opbd ) ) goto Exit; error = gx_face_load_LookupTable( face, stream, &(opbd->lookup_data) ); if ( error ) goto Exit; - + callback_data.extra = &opbd->format; error = gx_LookupTable_traverse_low( &(opbd->lookup_data), &funcs, @@ -878,14 +878,14 @@ gx_table_init(GX_Table table_info, return error; } - static FT_Error + static FT_Error opbd_lookup_table_generic_finalizer( GX_LookupTable_Format format, GX_LookupValue value, FT_Pointer user ) { FT_Memory memory = user; GX_OpticalBoundsData opbd_data; - + if ( !value->extra.opbd_data ) return GX_Err_Ok; @@ -913,24 +913,24 @@ gx_table_init(GX_Table table_info, /******************************LCAR************************************/ static FT_Error - gx_lcar_load_partials ( FT_Stream stream, + gx_lcar_load_partials ( FT_Stream stream, FT_UShort count, FT_Short *partials) { FT_Error error; FT_Int i; - + if ( FT_FRAME_ENTER ( sizeof( *partials ) * count ) ) goto Exit; - + for ( i = 0; i < count; i++ ) partials[i] = FT_GET_USHORT(); - + FT_FRAME_EXIT(); Exit: return error; } - + static FT_Error gx_lcar_load_class_entry ( GX_Face face, FT_Stream stream, @@ -941,10 +941,10 @@ gx_table_init(GX_Table table_info, FT_Memory memory = stream->memory; FT_UShort count; FT_Int base_size = sizeof (**class_entry); - + if ( FT_STREAM_SEEK(offset) ) goto Exit; - + if ( FT_READ_USHORT(count) ) goto Exit; @@ -954,15 +954,15 @@ gx_table_init(GX_Table table_info, return GX_Err_Ok; } - if ( FT_ALLOC ( *class_entry, + if ( FT_ALLOC ( *class_entry, base_size + count * sizeof(*(*class_entry)->partials) ) ) goto Exit; - + (*class_entry)->count = count; (*class_entry)->partials = (FT_Short *)(((char *)*class_entry) + base_size); - - error = gx_lcar_load_partials(stream, - (*class_entry)->count, + + error = gx_lcar_load_partials(stream, + (*class_entry)->count, (*class_entry)->partials); if ( error ) goto Failure; @@ -972,9 +972,9 @@ gx_table_init(GX_Table table_info, FT_FREE(*class_entry); *class_entry = NULL; return error; - + } - + static void gx_lcar_free_class_entry ( FT_Memory memory, GX_LigCaretClassEntry class_entry ) @@ -983,15 +983,15 @@ gx_table_init(GX_Table table_info, class_entry->partials = NULL; FT_FREE( class_entry ); } - - static FT_Error + + static FT_Error lcar_lookup_table_generic_loader( GX_LookupTable_Format format, GX_LookupValue value, FT_Pointer user ) { FT_Error error; GX_Face face = ((generic_lookup_table_cb_data)user)->face; - FT_Stream stream = ((generic_lookup_table_cb_data)user)->stream; + FT_Stream stream = ((generic_lookup_table_cb_data)user)->stream; FT_Short offset = value->raw.s; GX_LigCaretClassEntry class_entry; @@ -999,8 +999,8 @@ gx_table_init(GX_Table table_info, if ( ( error = face->goto_table( face, TTAG_lcar, stream, 0 ) ) ) return error; - if ( ( error = gx_lcar_load_class_entry ( face, - stream, + if ( ( error = gx_lcar_load_class_entry ( face, + stream, FT_STREAM_POS() + offset, &class_entry ) ) ) return error; @@ -1014,7 +1014,7 @@ gx_table_init(GX_Table table_info, FT_UShort firstGlyph, GX_LookupValue value, FT_Pointer user ) - + { FT_Error error; GX_Face face = ((generic_lookup_table_cb_data)user)->face; @@ -1026,33 +1026,33 @@ gx_table_init(GX_Table table_info, FT_UShort segment_count = lastGlyph - firstGlyph + 1; GX_LigCaretSegment segment; - + FT_Int i, j; - - /* disk seek chain: + + /* disk seek chain: 1. table_offset -> 2. value_offset -> 3. class_entry_offset */ - + /* 1. table_offset */ if ( (error = face->goto_table( face, TTAG_lcar, stream, 0 )) ) goto Exit; table_offset = FT_STREAM_POS(); - /* 2. value_offset + /* 2. value_offset * ----------------------------------------------------------------- - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING * Pfaedit will not work? - * In spec: "Sometimes they are 16-bit offsets from the start of + * In spec: "Sometimes they are 16-bit offsets from the start of * the table to the data. " The table? Is the table the lookup table * or a table that uses the lookup table? * Here I assume the table is the table that uses the lookup table. - * However, I have no conviction. + * However, I have no conviction. * As far as reading spec(fonts.apple.com/TTRefMan/RM06/Chap6lcar.html), * table_offset + value_offset is correct. It seems that pfaedit uses * lookup_table_offset + value_offset. * -----------------------------------------------------------------*/ if ( FT_STREAM_SEEK( table_offset + value_offset ) ) goto Exit; - + if ( FT_NEW_ARRAY ( segment, segment_count ) ) goto Exit; @@ -1061,15 +1061,15 @@ gx_table_init(GX_Table table_info, for ( i = 0; i < segment_count; i++ ) segment[i].offset = FT_GET_USHORT(); FT_FRAME_EXIT(); - + /* 3. class_entry_offset */ for ( i = 0; i < segment_count; i++ ) { segment[i].class_entry = NULL; - if (( error = gx_lcar_load_class_entry(face, stream, + if (( error = gx_lcar_load_class_entry(face, stream, table_offset + segment[i].offset, &(segment[i].class_entry)) )) - { + { /* Rewind to free the resources */ for ( j = i - 1; j >= 0; j-- ) { @@ -1088,14 +1088,14 @@ gx_table_init(GX_Table table_info, return error; } - + FT_LOCAL_DEF( FT_Error ) gx_face_load_lcar( GX_Face face, FT_Stream stream, GX_Lcar lcar ) { FT_Error error; - const FT_Frame_Field lcar_fields[] = + static const FT_Frame_Field lcar_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_LcarRec @@ -1111,7 +1111,7 @@ gx_table_init(GX_Table table_info, funcs.segment_array_func = lcar_lookup_table_segment_array_loader; callback_data.face = face; callback_data.stream = stream; - + /* FT_TRACE2(( "Ligature Caret" )); */ if (( error = gx_table_init( &(lcar->root), face, TTAG_lcar, stream, (GX_Table_Done_Func)gx_lcar_done) )) @@ -1129,7 +1129,7 @@ gx_table_init(GX_Table table_info, return error; } - static FT_Error + static FT_Error lcar_lookup_table_generic_finalizer( GX_LookupTable_Format format, GX_LookupValue value, FT_Pointer user ) @@ -1157,12 +1157,12 @@ gx_table_init(GX_Table table_info, GX_LigCaretSegment segment = value->extra.lcar_segment; FT_UShort segment_count = lastGlyph - firstGlyph; FT_Long i; - + if ( !segment ) return GX_Err_Ok; value->extra.lcar_segment = NULL; - + for ( i = 0; i < segment_count; i++ ) { gx_lcar_free_class_entry(memory, segment[i].class_entry); @@ -1175,7 +1175,7 @@ gx_table_init(GX_Table table_info, FT_LOCAL_DEF ( void ) gx_lcar_done( GX_Lcar lcar, FT_Memory memory ) - + { GX_LookupTable_FuncsRec funcs = GX_LOOKUP_TABLE_FUNC_ZERO; @@ -1199,7 +1199,7 @@ gx_table_init(GX_Table table_info, { FT_Error error; FT_Int i; - + if ( FT_FRAME_ENTER ( sizeof( *slots ) * GX_BSLN_VALUE_COUNT) ) return error; for ( i = 0; i < GX_BSLN_VALUE_COUNT; i++ ) @@ -1216,10 +1216,10 @@ gx_table_init(GX_Table table_info, FT_Error error; FT_Memory memory = stream->memory; GX_BaselineFormat0Part fmt0part; - + if ( FT_NEW( fmt0part ) ) goto Exit; - + if (( error = gx_bsln_load_32_ushort( face, stream, fmt0part->deltas ) )) goto Failure; parts->fmt0 = fmt0part; @@ -1247,22 +1247,22 @@ gx_table_init(GX_Table table_info, user_data.stream = stream; user_data.lookup_table = NULL; user_data.table_tag = 0; - + if ( FT_NEW ( fmt1part ) ) goto Exit; - - if (( error = gx_bsln_load_32_ushort( face, stream, + + if (( error = gx_bsln_load_32_ushort( face, stream, fmt1part->deltas ) )) goto Failure; - + lookup_table = &(fmt1part->mappingData); - if (( error = gx_face_load_LookupTable ( face, stream, + if (( error = gx_face_load_LookupTable ( face, stream, lookup_table ) )) goto Failure; if ( lookup_table->format == GX_LOOKUPTABLE_SEGMENT_ARRAY ) { user_data.lookup_table = lookup_table; - if (( error = gx_LookupTable_traverse_low( lookup_table, + if (( error = gx_LookupTable_traverse_low( lookup_table, &funcs, &user_data ) )) goto Failure_Lookup_Table; } @@ -1283,7 +1283,7 @@ gx_table_init(GX_Table table_info, { FT_Error error; FT_Memory memory = stream->memory; - GX_BaselineFormat2Part fmt2part; + GX_BaselineFormat2Part fmt2part; FT_UShort stdGlyph; if ( FT_READ_USHORT(stdGlyph) ) @@ -1291,11 +1291,11 @@ gx_table_init(GX_Table table_info, if ( FT_NEW( fmt2part ) ) goto Exit; - + fmt2part->stdGlyph = stdGlyph; - if (( error = gx_bsln_load_32_ushort( face, stream, + if (( error = gx_bsln_load_32_ushort( face, stream, fmt2part->ctlPoints ) )) - goto Failure; + goto Failure; parts->fmt2 = fmt2part; Exit: return error; @@ -1311,37 +1311,37 @@ gx_table_init(GX_Table table_info, { FT_Error error; FT_Memory memory = stream->memory; - GX_BaselineFormat3Part fmt3part; + GX_BaselineFormat3Part fmt3part; FT_UShort stdGlyph; - + GX_LookupTable lookup_table; - + GX_LookupTable_FuncsRec funcs = GX_LOOKUP_TABLE_FUNC_ZERO; generic_lookup_table_cb_data_rec user_data = GENERIC_LOOKUP_TABLE_CB_DATA_ZERO; funcs.segment_array_func = generic_lookup_table_segment_array_loader; user_data.face = face; user_data.stream = stream; - - if ( FT_READ_USHORT(stdGlyph) ) + + if ( FT_READ_USHORT(stdGlyph) ) goto Exit; if ( FT_NEW( fmt3part ) ) goto Exit; - + fmt3part->stdGlyph = stdGlyph; - if (( error = gx_bsln_load_32_ushort( face, stream, + if (( error = gx_bsln_load_32_ushort( face, stream, fmt3part->ctlPoints ) )) - goto Failure; + goto Failure; lookup_table = &(fmt3part->mappingData); - if (( error = gx_face_load_LookupTable ( face, stream, + if (( error = gx_face_load_LookupTable ( face, stream, lookup_table ) )) goto Failure; if ( lookup_table->format == GX_LOOKUPTABLE_SEGMENT_ARRAY ) { user_data.lookup_table = lookup_table; - if (( error = gx_LookupTable_traverse_low( lookup_table, + if (( error = gx_LookupTable_traverse_low( lookup_table, &funcs, &user_data ) )) goto Failure_Lookup_Table; } @@ -1354,8 +1354,8 @@ gx_table_init(GX_Table table_info, FT_FREE(fmt3part); return error; } - - + + FT_LOCAL_DEF( FT_Error ) gx_face_load_bsln( GX_Face face, FT_Stream stream, @@ -1364,7 +1364,7 @@ gx_table_init(GX_Table table_info, FT_Error error; gx_bsln_perfmt_loader fmt_loader; - const FT_Frame_Field bsln_fields[] = + static const FT_Frame_Field bsln_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_BslnRec @@ -1375,14 +1375,14 @@ gx_table_init(GX_Table table_info, FT_FRAME_END }; /* FT_TRACE2(( "Baseline" ));*/ - + if (( error = gx_table_init( &(bsln->root), face, TTAG_bsln, stream, (GX_Table_Done_Func)gx_bsln_done) )) goto Exit; - + if ( FT_STREAM_READ_FIELDS( bsln_fields, bsln ) ) goto Exit; - + switch ( bsln->format ) { case GX_BSLN_FMT_DISTANCE_NO_MAPPING: @@ -1409,7 +1409,7 @@ gx_table_init(GX_Table table_info, FT_LOCAL_DEF ( void ) gx_bsln_done( GX_Bsln bsln, FT_Memory memory ) - + { GX_BaselineParts parts = &bsln->parts; GX_LookupTable mappingData = NULL; @@ -1451,9 +1451,9 @@ gx_table_init(GX_Table table_info, if ( FT_NEW( rearrangement_body ) ) goto Exit; - - if (( error = gx_face_load_StateTable ( face, stream, - &rearrangement_body->state_table, + + if (( error = gx_face_load_StateTable ( face, stream, + &rearrangement_body->state_table, NULL, NULL ))) goto Failure; body->rearrangement = rearrangement_body; @@ -1463,7 +1463,7 @@ gx_table_init(GX_Table table_info, FT_FREE( rearrangement_body ); body->rearrangement = NULL; return error; - + } static void @@ -1474,7 +1474,7 @@ gx_table_init(GX_Table table_info, FT_FREE( rearrangement_body ); } - static FT_Error + static FT_Error gx_mort_load_contextual_subtable_entry( GX_Face face, FT_Stream stream, GX_EntrySubtable entry_subtable, @@ -1483,8 +1483,8 @@ gx_table_init(GX_Table table_info, FT_Error error; FT_Memory memory = stream->memory; GX_MetamorphosisContextualPerGlyph per_glyph; - - const FT_Frame_Field contextual_subtable_entry_fields[] = + + static const FT_Frame_Field contextual_subtable_entry_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_MetamorphosisContextualPerGlyphRec @@ -1510,7 +1510,7 @@ gx_table_init(GX_Table table_info, return error; } - static void + static void gx_mort_free_contextual_subtable_entry( FT_Memory memory, GX_EntrySubtable entry_subtable, FT_Pointer user ) @@ -1538,12 +1538,12 @@ gx_table_init(GX_Table table_info, if ( FT_NEW( contextual_body ) ) goto Exit; - - if (( error = gx_face_load_StateTable ( face, stream, - &contextual_body->state_table, + + if (( error = gx_face_load_StateTable ( face, stream, + &contextual_body->state_table, &funcs, NULL) )) goto Failure; - + state_header = &contextual_body->state_table.header; substitutionTable = &contextual_body->substitutionTable; if ( FT_STREAM_SEEK( state_header->position + GX_STATE_HEADER_ADVANCE ) || @@ -1551,17 +1551,17 @@ gx_table_init(GX_Table table_info, goto Failure_stateTable; substitutionTable->nGlyphIndexes = (length - substitutionTable->offset)/2; - + substitutionTable->glyph_indexes = NULL; - if ( FT_NEW_ARRAY( substitutionTable->glyph_indexes, + if ( FT_NEW_ARRAY( substitutionTable->glyph_indexes, substitutionTable->nGlyphIndexes ) ) goto Failure_stateTable; - if ( FT_STREAM_SEEK( state_header->position + if ( FT_STREAM_SEEK( state_header->position + substitutionTable->offset ) ) goto Failure_substitutionTable; if ( FT_FRAME_ENTER( substitutionTable->nGlyphIndexes * sizeof( substitutionTable->glyph_indexes[0] ) )) goto Failure_substitutionTable; - + for ( i = 0; i < substitutionTable->nGlyphIndexes; i++ ) substitutionTable->glyph_indexes[i] = FT_GET_USHORT(); FT_FRAME_EXIT(); @@ -1578,7 +1578,7 @@ gx_table_init(GX_Table table_info, FT_FREE( contextual_body ); body->contextual = NULL; return error; - + } static void @@ -1586,11 +1586,11 @@ gx_table_init(GX_Table table_info, GX_MetamorphosisContextualBody contextual_body ) { GX_MetamorphosisContextualSubstitutionTable substitutionTable; - + substitutionTable = &contextual_body->substitutionTable;; FT_FREE( substitutionTable->glyph_indexes ); substitutionTable->glyph_indexes = NULL; - gx_StateTable_free( &contextual_body->state_table, + gx_StateTable_free( &contextual_body->state_table, memory, gx_mort_free_contextual_subtable_entry, NULL ); @@ -1610,7 +1610,7 @@ gx_table_init(GX_Table table_info, } static FT_UShort - gx_mort_count_ligAction_entry(GX_Face face, + gx_mort_count_ligAction_entry(GX_Face face, GX_MetamorphosisLigatureBody ligature_body) { FT_UShort max_offset = 0; @@ -1623,7 +1623,7 @@ gx_table_init(GX_Table table_info, ?(((max_offset - ligature_body->ligActionTable.offset)/sizeof(FT_ULong)) + 1) : max_offset; } -#endif /* 0 */ +#endif /* 0 */ static FT_Error gx_mort_load_ligature_subtable( GX_Face face, FT_Stream stream, @@ -1642,18 +1642,18 @@ gx_table_init(GX_Table table_info, if ( FT_NEW( ligature_body ) ) goto Exit; - + if (( error = gx_face_load_StateTable( face, stream, &ligature_body->state_table, NULL, NULL ))) goto Failure; - + state_header = &ligature_body->state_table.header; ligActionTable = &ligature_body->ligActionTable; componentTable = &ligature_body->componentTable; ligatureTable = &ligature_body->ligatureTable; if ( FT_STREAM_SEEK( state_header->position + GX_STATE_HEADER_ADVANCE ) || - FT_FRAME_ENTER( sizeof( ligActionTable->offset ) + FT_FRAME_ENTER( sizeof( ligActionTable->offset ) + sizeof( componentTable->offset ) + sizeof( ligatureTable->offset ))) goto Failure_stateTable; @@ -1663,13 +1663,13 @@ gx_table_init(GX_Table table_info, FT_FRAME_EXIT(); /* ----------------------------------------------------------------- - * Calculate the order of tables: ligActionTable, componentTable and + * Calculate the order of tables: ligActionTable, componentTable and * ligatureTable * ----------------------------------------------------------------- */ generic_triple_offset_diff(ligActionTable->offset, componentTable->offset, ligatureTable->offset, - length, + length, &ligActionTable->nActions, &componentTable->nComponent, &ligatureTable->nLigature); - + /* Load ligActionTable */ #if 0 ligActionTable->nActions = gx_mort_count_ligAction_entry( face, @@ -1685,8 +1685,8 @@ gx_table_init(GX_Table table_info, for ( i = 0; i < ligActionTable->nActions; i++ ) ligActionTable->body[i] = FT_GET_ULONG(); FT_FRAME_EXIT(); - - + + /* Load componentTable */ componentTable->body = NULL; if ( FT_NEW_ARRAY ( componentTable->body, componentTable->nComponent ) ) @@ -1721,7 +1721,7 @@ gx_table_init(GX_Table table_info, FT_FREE (ligActionTable->body); ligActionTable->body = NULL; Failure_stateTable: - gx_StateTable_free( &ligature_body->state_table, + gx_StateTable_free( &ligature_body->state_table, memory, NULL, /* CHECK, Thu Oct 23 14:14:43 2003 */ NULL); @@ -1744,8 +1744,8 @@ gx_table_init(GX_Table table_info, componentTable->body = NULL; FT_FREE (ligActionTable->body); ligActionTable->body = NULL; - gx_StateTable_free( &ligature_body->state_table, - memory, + gx_StateTable_free( &ligature_body->state_table, + memory, NULL, /* CHECK, Thu Oct 23 14:14:43 2003 */ NULL ); FT_FREE( ligature_body ); @@ -1761,7 +1761,7 @@ gx_table_init(GX_Table table_info, } static void - gx_mort_free_noncontextual_subtable( FT_Memory memory, + gx_mort_free_noncontextual_subtable( FT_Memory memory, GX_MetamorphosisNoncontextualBody noncontextual_body ) { GX_LookupTable lookup_table = &noncontextual_body->lookup_table; @@ -1788,17 +1788,17 @@ gx_table_init(GX_Table table_info, FT_Int i; if ( FT_STREAM_SEEK( pos ) ) return error; - + if (FT_FRAME_ENTER( sizeof ( glyphcodes[0] ) * count ) ) return error; for ( i = 0; i < count; i++ ) glyphcodes[i] = FT_GET_USHORT(); FT_FRAME_EXIT(); - + return GX_Err_Ok;; } - static FT_Error + static FT_Error gx_mort_load_insertion_subtable_entry( GX_Face face, FT_Stream stream, GX_EntrySubtable entry_subtable, @@ -1812,15 +1812,15 @@ gx_table_init(GX_Table table_info, GX_StateHeader state_header = &(state_table->header); GX_MetamorphosisInsertionPerGlyph per_glyph; - FT_UShort current_count = gx_mask_zero_shift(entry_subtable->flags, + FT_UShort current_count = gx_mask_zero_shift(entry_subtable->flags, GX_MORT_INSERTION_FLAGS_CURRENT_INSERT_COUNT); - FT_UShort marked_count = gx_mask_zero_shift(entry_subtable->flags, + FT_UShort marked_count = gx_mask_zero_shift(entry_subtable->flags, GX_MORT_INSERTION_FLAGS_MARKED_INSERT_COUNT); GX_MetamorphosisInsertionList currentInsertList; GX_MetamorphosisInsertionList markedInsertList; FT_ULong tmp_pos; - const FT_Frame_Field insertion_subtable_entry_fields[] = + static const FT_Frame_Field insertion_subtable_entry_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_MetamorphosisInsertionPerGlyphRec @@ -1830,8 +1830,8 @@ gx_table_init(GX_Table table_info, FT_FRAME_END }; - if ( FT_ALLOC ( per_glyph, - sizeof(per_glyph) + + if ( FT_ALLOC ( per_glyph, + sizeof(per_glyph) + (current_count * sizeof(currentInsertList->glyphcodes[0]) ) + (marked_count * sizeof(markedInsertList->glyphcodes[0]) )) ) goto Exit; @@ -1840,12 +1840,12 @@ gx_table_init(GX_Table table_info, markedInsertList = &per_glyph->markedInsertList; currentInsertList->glyphcodes = (FT_UShort *)(((char *)per_glyph) + sizeof(per_glyph)); markedInsertList->glyphcodes = currentInsertList->glyphcodes + current_count; - + if ( FT_STREAM_READ_FIELDS ( insertion_subtable_entry_fields, per_glyph ) ) goto Failure; - - + + /* TODO: Should optimize. Being `offset' zero means, there is no insertion. But we can know whether the `offset' is zero or not after reading fields. @@ -1854,7 +1854,7 @@ gx_table_init(GX_Table table_info, current_count = 0; if ( !per_glyph->markedInsertList.offset ) marked_count = 0; - + tmp_pos = FT_STREAM_POS(); if ( (error = gx_mort_load_insertion_glyphcodes ( face, stream, @@ -1868,7 +1868,7 @@ gx_table_init(GX_Table table_info, marked_count, markedInsertList->glyphcodes) ) ) goto Failure; - + if ( FT_STREAM_SEEK( tmp_pos ) ) goto Failure; entry_subtable->glyphOffsets.insertion = per_glyph; @@ -1880,7 +1880,7 @@ gx_table_init(GX_Table table_info, return error; } - static void + static void gx_mort_free_insertion_subtable_entry( FT_Memory memory, GX_EntrySubtable entry_subtable, FT_Pointer user ) @@ -1905,7 +1905,7 @@ gx_table_init(GX_Table table_info, if ( FT_NEW( insertion_body ) ) goto Exit; - + if (( error = gx_face_load_StateTable( face, stream, &insertion_body->state_table, &funcs, insertion_body ) )) @@ -1917,7 +1917,7 @@ gx_table_init(GX_Table table_info, FT_FREE(insertion_body); body->insertion = NULL; return error; - + } static void @@ -1931,13 +1931,13 @@ gx_table_init(GX_Table table_info, FT_FREE(insertion_body); } - static FT_Error + static FT_Error gx_mort_load_subtable_header( GX_Face face, FT_Stream stream, GX_MetamorphosisSubtableHeader header ) { FT_Error error; - const FT_Frame_Field mort_subtable_header_fileds[] = + static const FT_Frame_Field mort_subtable_header_fileds[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_MetamorphosisSubtableHeaderRec @@ -1962,18 +1962,18 @@ gx_table_init(GX_Table table_info, FT_UShort subtable_type; gx_mort_subtable_loader loader; FT_UShort header_size = sizeof(header->length) - + sizeof(header->coverage) + + sizeof(header->coverage) + sizeof(header->subFeatureFlags); - + if ( FT_STREAM_SEEK ( pos ) ) goto Exit; - + header = &chain_Subtbl->header; if (( error = gx_mort_load_subtable_header ( face, stream, header ))) goto Exit; - + subtable_type = header->coverage & GX_MORT_COVERAGE_SUBTABLE_TYPE; FT_TRACE2(( " mort subtable format %d\n", subtable_type )); switch ( subtable_type ) @@ -2008,7 +2008,7 @@ gx_table_init(GX_Table table_info, { GX_MetamorphosisSubtableHeader header; FT_UShort subtable_type; - + header = &chain_Subtbl->header; subtable_type = header->coverage & GX_MORT_COVERAGE_SUBTABLE_TYPE; switch ( subtable_type ) @@ -2041,7 +2041,7 @@ gx_table_init(GX_Table table_info, GX_MetamorphosisFeatureTable feat_Subtbl ) { FT_Error error; - const FT_Frame_Field mort_feature_table_fileds[] = + static const FT_Frame_Field mort_feature_table_fileds[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_MetamorphosisFeatureTableRec @@ -2051,19 +2051,19 @@ gx_table_init(GX_Table table_info, FT_FRAME_ULONG ( enableFlags ), FT_FRAME_ULONG ( disableFlags ), FT_FRAME_END - }; - + }; + return FT_STREAM_READ_FIELDS( mort_feature_table_fileds, feat_Subtbl ); } - + static FT_Error gx_mort_load_chain_header( GX_Face face, FT_Stream stream, GX_MetamorphosisChainHeader header ) { FT_Error error; - - const FT_Frame_Field mort_chain_header_fields[] = + + static const FT_Frame_Field mort_chain_header_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_MetamorphosisChainHeaderRec @@ -2091,16 +2091,16 @@ gx_table_init(GX_Table table_info, GX_MetamorphosisSubtable chain_Subtbl = NULL; FT_ULong subtbl_start; FT_Int i, j; - + header = &(chain->header); if ( FT_STREAM_SEEK ( pos ) || ( error = gx_mort_load_chain_header(face, stream, header )) || FT_NEW_ARRAY ( feat_Subtbl, header->nFeatureEntries ) ) goto Exit; - + for ( i = 0; i < header->nFeatureEntries; i++ ) { - if (( error = gx_mort_load_feature_table( face, stream, + if (( error = gx_mort_load_feature_table( face, stream, &feat_Subtbl[i] ) )) goto Failure; } @@ -2125,7 +2125,7 @@ gx_table_init(GX_Table table_info, Exit: return error; Failure: - chain->feat_Subtbl = NULL; + chain->feat_Subtbl = NULL; chain->chain_Subtbl = NULL; if ( feat_Subtbl ) FT_FREE ( feat_Subtbl ); @@ -2158,10 +2158,10 @@ gx_table_init(GX_Table table_info, FT_Error error; FT_Memory memory = stream->memory; GX_MetamorphosisChain chain; - + FT_ULong chain_start_pos; FT_Int i, j; - const FT_Frame_Field mort_fields[] = + static const FT_Frame_Field mort_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_MortRec @@ -2175,7 +2175,7 @@ gx_table_init(GX_Table table_info, (GX_Table_Done_Func)gx_mort_done) )) goto Exit; - mort->chain = NULL; + mort->chain = NULL; if ( FT_STREAM_READ_FIELDS( mort_fields, mort ) ) goto Exit; @@ -2185,8 +2185,8 @@ gx_table_init(GX_Table table_info, chain_start_pos = FT_STREAM_POS(); for ( i = 0; i < mort->nChains; i++ ) { - if (( error = gx_mort_load_chain( face, - stream, chain_start_pos, + if (( error = gx_mort_load_chain( face, + stream, chain_start_pos, &chain[i] ) )) { for ( j = i - 1; j >= 0; j-- ) @@ -2206,10 +2206,10 @@ gx_table_init(GX_Table table_info, FT_LOCAL_DEF ( void ) gx_mort_done( GX_Mort mort, FT_Memory memory ) - + { FT_Int i; - + for ( i = 0; i < mort->nChains; i++ ) gx_mort_free_chain( memory, &mort->chain[i] ); FT_FREE( mort->chain ); @@ -2222,8 +2222,8 @@ gx_table_init(GX_Table table_info, static void gx_morx_free_chain( FT_Memory memory, GX_XMetamorphosisChain chain ); static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable chain_Subtbl ); -#define gx_morx_load_feature_table gx_mort_load_feature_table -#define gx_morx_free_feature_table gx_mort_free_feature_table +#define gx_morx_load_feature_table gx_mort_load_feature_table +#define gx_morx_free_feature_table gx_mort_free_feature_table typedef FT_Error (* gx_morx_subtable_loader) ( GX_Face face, FT_Stream stream, @@ -2236,8 +2236,8 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c GX_XMetamorphosisChainHeader header ) { FT_Error error; - - const FT_Frame_Field morx_chain_header_fields[] = + + static const FT_Frame_Field morx_chain_header_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_XMetamorphosisChainHeaderRec @@ -2264,8 +2264,8 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c if ( FT_NEW( rearrangement_body ) ) goto Exit; - - if (( error = gx_face_load_XStateTable ( face, stream, + + if (( error = gx_face_load_XStateTable ( face, stream, &rearrangement_body->state_table, NULL, NULL ) )) @@ -2282,7 +2282,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c /* * Contextual */ - static FT_Error + static FT_Error gx_morx_load_contextual_subtable_entry( GX_Face face, FT_Stream stream, GX_EntrySubtable entry_subtable, @@ -2290,9 +2290,9 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c { FT_Error error; FT_Memory memory = stream->memory; - + GX_XMetamorphosisContextualPerGlyph per_glyph; - const FT_Frame_Field contextual_subtable_entry_fields[] = + static const FT_Frame_Field contextual_subtable_entry_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_XMetamorphosisContextualPerGlyphRec @@ -2318,7 +2318,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c return error; } - static void + static void gx_morx_free_contextual_subtable_entry( FT_Memory memory, GX_EntrySubtable entry_subtable, FT_Pointer user ) @@ -2337,17 +2337,17 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c GX_XMetamorphosisContextualPerGlyph per_glyph = entry_subtable->glyphOffsets.xcontextual; FT_UShort markIndex = per_glyph->markIndex; FT_UShort currentIndex = per_glyph->currentIndex; - + if ( markIndex == GX_MORX_NO_SUBSTITUTION ) markIndex = 0; if ( currentIndex == GX_MORX_NO_SUBSTITUTION ) currentIndex = 0; - + if ( markIndex < currentIndex ) local_max_index = currentIndex; else local_max_index = markIndex; - + if ( *max_index < local_max_index ) *max_index = local_max_index; return GX_Err_Ok; @@ -2380,13 +2380,13 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c user_data.face = face; user_data.stream = stream; /* ----------------------------------------------------------------- - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING * Next code is correct? * ----------------------------------------------------------------- */ user_data.table_tag = 0; - + *lookup_table = NULL; - + if ( FT_STREAM_SEEK(pos) ) goto Exit; @@ -2403,7 +2403,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c &user_data ))) goto Failure_Lookup_Table; } - + *lookup_table = local_lookup_table; Exit: return error; @@ -2419,9 +2419,9 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c GX_LookupTable lookup_table ) { GX_LookupTable_FuncsRec funcs = GX_LOOKUP_TABLE_FUNC_ZERO; - + funcs.segment_array_func = generic_lookup_table_segment_array_finalizer; - + if ( lookup_table->format == GX_LOOKUPTABLE_SEGMENT_ARRAY ) gx_LookupTable_traverse_low ( lookup_table, &funcs, @@ -2438,16 +2438,16 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_Error error = GX_Err_Ok; FT_Stream stream = data->stream; GX_XMetamorphosisContextualSubstitutionTable substitution_table = data->extra; - + GX_XMetamorphosisContextualPerGlyph per_glyph = entry_subtable->glyphOffsets.xcontextual; FT_UShort markIndex = per_glyph->markIndex; FT_UShort currentIndex = per_glyph->currentIndex; GX_LookupTable mark_table = NULL; GX_LookupTable current_table = NULL; - FT_ULong pos; + FT_ULong pos; - if ( ( markIndex != GX_MORX_NO_SUBSTITUTION ) && + if ( ( markIndex != GX_MORX_NO_SUBSTITUTION ) && (! substitution_table->lookupTables[markIndex] ) ) { pos = data->base + data->table_offset + (sizeof(mark_table->position) * markIndex); @@ -2529,7 +2529,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c if ( FT_NEW( contextual_body ) ) goto Exit; - + state_table = &contextual_body->state_table; if (( error = gx_face_load_XStateTable( face, stream, state_table, @@ -2543,7 +2543,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c goto Failure_XStateTable; if ( FT_READ_ULONG ( substitution_table->offset ) ) goto Failure_XStateTable; - + substitution_table->nTables = gx_morx_count_lookup_table(face, state_table); if ( FT_NEW_ARRAY ( substitution_table->lookupTables, @@ -2551,7 +2551,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c goto Failure_XStateTable; for ( i = 0; i < substitution_table->nTables; i++ ) substitution_table->lookupTables[i] = NULL; - + if (( error = gx_morx_load_contextual_substitution_table( face, stream, state_table, @@ -2583,12 +2583,12 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c { FT_Error error; FT_UShort per_glyph; - + /* ----------------------------------------------------------------- - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING * Should I read ushort even if entry_subtable->flags&GX_MORX_LIGATURE_FLAGS_PERFORM_ACTION - * is 0? - * ----------------------------------------------------------------- */ + * is 0? + * ----------------------------------------------------------------- */ if ( FT_READ_USHORT ( per_glyph ) ) goto Exit; entry_subtable->glyphOffsets.ligActionIndex = per_glyph; @@ -2602,21 +2602,21 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_Pointer user ) { FT_Long * max_index = (FT_Long *)user; - if ( ( entry_subtable->flags & GX_MORX_LIGATURE_FLAGS_PERFORM_ACTION ) && + if ( ( entry_subtable->flags & GX_MORX_LIGATURE_FLAGS_PERFORM_ACTION ) && (*max_index < entry_subtable->glyphOffsets.ligActionIndex ) ) *max_index = (FT_Long)entry_subtable->glyphOffsets.ligActionIndex; return GX_Err_Ok; } static FT_UShort - gx_morx_count_ligAction_entry(GX_Face face, + gx_morx_count_ligAction_entry(GX_Face face, GX_XMetamorphosisLigatureBody ligature_body) { FT_Long max_index = -1; gx_XStateTable_traverse_entries( &ligature_body->state_table, morx_max_ligAction_index, &max_index ); - + return (FT_UShort)(max_index + 1); } #endif /* 0 */ @@ -2644,7 +2644,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c if (( error = gx_face_load_XStateTable( face, stream, &ligature_body->state_table, - &funcs, + &funcs, NULL ))) goto Failure; state_header = &ligature_body->state_table.header; @@ -2668,7 +2668,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c & ligActionTable->nActions, & componentTable->nComponent, & ligatureTable->nLigature ); - + /* Load ligActionTable */ #if 0 ligActionTable->nActions = gx_morx_count_ligAction_entry( face, @@ -2685,7 +2685,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c for ( i = 0; i < ligActionTable->nActions; i++ ) ligActionTable->body[i] = FT_GET_ULONG(); FT_FRAME_EXIT(); - + /* Load componentTable */ componentTable->body = NULL; if ( FT_NEW_ARRAY ( componentTable->body, componentTable->nComponent ) ) @@ -2701,7 +2701,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c ligatureTable->body = NULL; if ( FT_NEW_ARRAY ( ligatureTable->body, ligatureTable->nLigature ) ) - goto Failure_componentTable; + goto Failure_componentTable; if ( FT_STREAM_SEEK ( state_header->position + ligatureTable->offset ) ) goto Failure_ligatureTable; if ( FT_FRAME_ENTER ( ligatureTable->nLigature * sizeof ( ligatureTable->body[0] ) ) ) @@ -2748,7 +2748,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c { FT_Error error; GX_MetamorphosisSubtableBodyDesc mort_body; - + if (( error = generic_load_noncontextual_subtable ( face, stream, length, @@ -2764,7 +2764,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c /* * Insertion */ - static FT_Error + static FT_Error gx_morx_load_insertion_subtable_entry( GX_Face face, FT_Stream stream, GX_EntrySubtable entry_subtable, @@ -2773,14 +2773,14 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_Error error; FT_Memory memory = stream->memory; GX_XMetamorphosisInsertionPerGlyph per_glyph; - FT_UShort current_count = gx_mask_zero_shift(entry_subtable->flags, + FT_UShort current_count = gx_mask_zero_shift(entry_subtable->flags, GX_MORX_INSERTION_FLAGS_CURRENT_INSERT_COUNT); - FT_UShort marked_count = gx_mask_zero_shift(entry_subtable->flags, + FT_UShort marked_count = gx_mask_zero_shift(entry_subtable->flags, GX_MORX_INSERTION_FLAGS_MARKED_INSERT_COUNT); GX_XMetamorphosisInsertionList currentInsertList; GX_XMetamorphosisInsertionList markedInsertList; - const FT_Frame_Field insertion_subtable_entry_fields[] = + static const FT_Frame_Field insertion_subtable_entry_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_XMetamorphosisInsertionPerGlyphRec @@ -2792,11 +2792,11 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c /* TODO: Should optimize. Being `offset' GX_MORX_NO_INSERTION means, there is no insertion. - But we can know whether the `offset' is GX_MORX_NO_INSERTION or not after - reading fields. Some memory area(->glyphcodes) allocated before reading + But we can know whether the `offset' is GX_MORX_NO_INSERTION or not after + reading fields. Some memory area(->glyphcodes) allocated before reading fields are wasted. See also `morx_load_insertion_glyphcodes'. */ - if ( FT_ALLOC ( per_glyph, - sizeof(per_glyph) + + if ( FT_ALLOC ( per_glyph, + sizeof(per_glyph) + current_count * sizeof(currentInsertList->glyphcodes[0]) + marked_count * sizeof(markedInsertList->glyphcodes[0])) ) goto Exit; @@ -2805,7 +2805,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c markedInsertList = &per_glyph->markedInsertList; currentInsertList->glyphcodes = (FT_UShort *)(((char *)per_glyph) + sizeof(per_glyph)); markedInsertList->glyphcodes = currentInsertList->glyphcodes + current_count; - + if ( FT_STREAM_READ_FIELDS ( insertion_subtable_entry_fields, per_glyph ) ) goto Failure; @@ -2819,7 +2819,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c return error; } - static void + static void gx_morx_free_insertion_subtable_entry( FT_Memory memory, GX_EntrySubtable entry_subtable, FT_Pointer user ) @@ -2841,12 +2841,12 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c GX_XMetamorphosisInsertionPerGlyph per_glyph = entry_subtable->glyphOffsets.insertion; GX_XMetamorphosisInsertionList currentInsertList = &per_glyph->currentInsertList; GX_XMetamorphosisInsertionList markedInsertList = &per_glyph->markedInsertList; - FT_UShort current_count = gx_mask_zero_shift(entry_subtable->flags, + FT_UShort current_count = gx_mask_zero_shift(entry_subtable->flags, GX_MORX_INSERTION_FLAGS_CURRENT_INSERT_COUNT); - FT_UShort marked_count = gx_mask_zero_shift(entry_subtable->flags, + FT_UShort marked_count = gx_mask_zero_shift(entry_subtable->flags, GX_MORX_INSERTION_FLAGS_MARKED_INSERT_COUNT); FT_Int i; - + /* Dirty hack here. See */ if ( per_glyph->currentInsertList.offset == GX_MORX_NO_INSERTION ) current_count = 0; @@ -2860,7 +2860,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c if ( FT_READ_USHORT ( currentInsertList->glyphcodes[i] ) ) return error; } - + if ( FT_STREAM_SEEK( pos + markedInsertList->offset ) ) return error; for ( i = 0; i < marked_count; i++ ) @@ -2887,7 +2887,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c funcs.loader = gx_morx_load_insertion_subtable_entry; funcs.finalizer = gx_morx_free_insertion_subtable_entry; - + if ( FT_NEW( insertion_body ) ) goto Exit; @@ -2907,7 +2907,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c traverse_data.stream = stream; traverse_data.face = face; traverse_data.extra = NULL; - if (( error = gx_XStateTable_traverse_entries ( state_table, + if (( error = gx_XStateTable_traverse_entries ( state_table, morx_load_insertion_glyphcodes, &traverse_data ) )) goto Failure_XStateTable; @@ -2916,13 +2916,13 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c return error; Failure_XStateTable: gx_XStateTable_free( &insertion_body->state_table, - memory, + memory, gx_morx_free_insertion_subtable_entry, NULL ); Failure: FT_FREE(insertion_body); body->insertion = NULL; - return error; + return error; } static FT_Error @@ -2931,7 +2931,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c GX_XMetamorphosisSubtableHeader header ) { FT_Error error; - const FT_Frame_Field morx_subtable_header_fileds[] = + static const FT_Frame_Field morx_subtable_header_fileds[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_XMetamorphosisSubtableHeaderRec @@ -2958,7 +2958,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c + sizeof(header->subFeatureFlags); FT_ULong subtable_type; gx_morx_subtable_loader loader; - + if ( FT_STREAM_SEEK ( pos ) ) goto Exit; @@ -3029,7 +3029,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c &feat_Subtbl[i] ) )) goto Failure; } - + subtbl_start = FT_STREAM_POS(); if ( FT_NEW_ARRAY ( chain_Subtbl, header->nSubtables ) ) goto Failure; @@ -3066,9 +3066,9 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_Error error; FT_Memory memory = stream->memory; GX_XMetamorphosisChain chain; - + FT_ULong chain_start_pos; - const FT_Frame_Field morx_fields[] = + static const FT_Frame_Field morx_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_MorxRec @@ -3078,7 +3078,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_FRAME_END }; FT_ULong i, j; - + /* FT_TRACE2(( "MetamorphosisX Table" )); */ if (( error = gx_table_init( &(morx->root), face, TTAG_morx, stream, (GX_Table_Done_Func)gx_morx_done) )) @@ -3088,7 +3088,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c if ( FT_STREAM_READ_FIELDS( morx_fields, morx ) ) goto Exit; - + if ( FT_NEW_ARRAY( chain, morx->nChains ) ) goto Exit; @@ -3128,13 +3128,13 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c gx_morx_free_contextual_substitution_table ( FT_Memory memory, GX_XMetamorphosisContextualSubstitutionTable substitution_table ) { FT_Int i; - + for ( i = substitution_table->nTables; i > 0; i-- ) { if ( !substitution_table->lookupTables[i - 1] ) continue ; else - { + { gx_morx_free_lookup_table ( memory, substitution_table->lookupTables[i - 1] ); substitution_table->lookupTables[i - 1] = NULL; } @@ -3147,7 +3147,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c GX_XMetamorphosisContextualBody contextual_body = body->contextual; GX_XMetamorphosisContextualSubstitutionTable substitutionTable = &contextual_body->substitutionTable; GX_LookupTable * lookup_tables = substitutionTable->lookupTables; - gx_morx_free_contextual_substitution_table ( memory, + gx_morx_free_contextual_substitution_table ( memory, substitutionTable ); substitutionTable->lookupTables = NULL; FT_FREE( lookup_tables ); @@ -3173,8 +3173,8 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c componentTable->body = NULL; FT_FREE (ligActionTable->body); ligActionTable->body = NULL; - gx_XStateTable_free( &ligature_body->state_table, - memory, + gx_XStateTable_free( &ligature_body->state_table, + memory, NULL, /* CHECK, Thu Oct 23 14:14:43 2003 */ NULL); FT_FREE( ligature_body ); @@ -3184,19 +3184,19 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c gx_morx_free_noncontextual_subtable ( FT_Memory memory, GX_XMetamorphosisSubtableBody body ) { GX_XMetamorphosisNoncontextualBody noncontextual_body = body->noncontextual; - + gx_mort_free_noncontextual_subtable ( memory, noncontextual_body ); body->noncontextual = NULL; } - + static void gx_morx_free_insertion_subtable ( FT_Memory memory, GX_XMetamorphosisSubtableBody body ) { GX_XMetamorphosisInsertionBody insertion_body = body->insertion; GX_XStateTable state_table = &insertion_body->state_table; - + gx_XStateTable_free( state_table, - memory, + memory, gx_morx_free_insertion_subtable_entry, NULL ); FT_FREE(insertion_body); @@ -3208,7 +3208,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c { GX_XMetamorphosisSubtableHeader header; FT_ULong subtable_type; - + header = &chain_Subtbl->header; subtable_type = header->coverage & GX_MORX_COVERAGE_SUBTABLE_TYPE; switch ( subtable_type ) @@ -3240,14 +3240,14 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c { GX_XMetamorphosisChainHeader header; FT_ULong i; - + header = &(chain->header); for ( i = header->nSubtables; i > 0; i-- ) - gx_morx_free_subtable( memory, + gx_morx_free_subtable( memory, &chain->chain_Subtbl[i - 1] ); FT_FREE(chain->chain_Subtbl); chain->chain_Subtbl = NULL; - + FT_FREE(chain->feat_Subtbl); chain->feat_Subtbl = NULL; } @@ -3255,10 +3255,10 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_LOCAL_DEF ( void ) gx_morx_done( GX_Morx morx, FT_Memory memory ) - + { FT_ULong i; - + for ( i = morx->nChains ; i > 0 ; i-- ) gx_morx_free_chain( memory, &morx->chain[i - 1] ); FT_FREE( morx->chain ); @@ -3273,8 +3273,8 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c GX_Fmtx fmtx ) { FT_Error error; - - const FT_Frame_Field fmtx_fields[] = + + static const FT_Frame_Field fmtx_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_FmtxRec @@ -3305,7 +3305,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_LOCAL_DEF ( void ) gx_fmtx_done( GX_Fmtx fmtx, FT_Memory memory ) - + { /* DO NOTHING */ } @@ -3318,7 +3318,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c GX_FontDescriptor desc ) { FT_Error error = GX_Err_Ok; - const FT_Frame_Field fdsc_desc_fields[] = + static const FT_Frame_Field fdsc_desc_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_FontDescriptorRec @@ -3349,7 +3349,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c GX_FontDescriptor desc; - const FT_Frame_Field fdsc_fields[] = + static const FT_Frame_Field fdsc_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_FdscRec @@ -3363,17 +3363,17 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c if (( error = gx_table_init( &(fdsc->root), face, TTAG_fdsc, stream, (GX_Table_Done_Func)gx_fdsc_done) )) goto Exit; - + if ( FT_STREAM_READ_FIELDS( fdsc_fields, fdsc ) ) goto Exit; - + if ( FT_NEW_ARRAY(desc, fdsc->descriptorCount) ) goto Exit; - if (( error = gx_fdsc_load_descriptor(face, stream, + if (( error = gx_fdsc_load_descriptor(face, stream, fdsc->descriptorCount, desc ))) goto Failure; - + fdsc->descriptor = desc; Exit: return error; @@ -3385,14 +3385,14 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_LOCAL_DEF( void ) gx_fdsc_done( GX_Fdsc fdsc, FT_Memory memory ) - + { if ( fdsc->descriptorCount ) { FT_FREE( fdsc->descriptor ); fdsc->descriptor = NULL; } - + } @@ -3405,7 +3405,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c { FT_Error error; - const FT_Frame_Field just_fields[] = + static const FT_Frame_Field just_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_JustRec @@ -3416,12 +3416,12 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_FRAME_USHORT ( vertOffset ), FT_FRAME_END }; - + /* FT_TRACE2(( "Justification " )); */ if (( error = gx_table_init( &(just->root), face, TTAG_just, stream, (GX_Table_Done_Func)gx_just_done) )) goto Exit; - + if ( FT_STREAM_READ_FIELDS( just_fields, just ) ) goto Exit; /* TODO: just */ @@ -3429,11 +3429,11 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c Exit: return error; } - + FT_LOCAL_DEF ( void ) gx_just_done( GX_Just just, FT_Memory memory ) - + { /* TODO */ } @@ -3448,7 +3448,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c { FT_Error error; - const FT_Frame_Field kern_subtable_header_fields[] = + static const FT_Frame_Field kern_subtable_header_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_KerningSubtableHeaderRec @@ -3458,26 +3458,26 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_FRAME_USHORT( tupleIndex ), FT_FRAME_END }; - + header->position = FT_STREAM_POS(); - if ( FT_STREAM_READ_FIELDS( kern_subtable_header_fields, + if ( FT_STREAM_READ_FIELDS( kern_subtable_header_fields, header ) ) goto Exit; - Exit: + Exit: return error; } static FT_Error gx_kern_load_fmt0_subtable ( GX_Face face, FT_Stream stream, - GX_KerningSubtableHeader header, + GX_KerningSubtableHeader header, GX_KerningSubtableFormat0Body fmt0 ) { FT_Error error; FT_Memory memory = stream->memory; GX_KerningSubtableFormat0Entry entries; FT_Int i; - - const FT_Frame_Field kern_fmt0_subtable_fields [] = + + static const FT_Frame_Field kern_fmt0_subtable_fields [] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_KerningSubtableFormat0BodyRec @@ -3489,7 +3489,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_FRAME_END }; - const FT_Frame_Field kern_fmt0_entry_fields [] = + static const FT_Frame_Field kern_fmt0_entry_fields [] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_KerningSubtableFormat0EntryRec @@ -3499,11 +3499,11 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_FRAME_SHORT ( value ), FT_FRAME_END }; - + if ( FT_STREAM_READ_FIELDS( kern_fmt0_subtable_fields, fmt0 ) ) goto Exit; - + if ( FT_NEW_ARRAY ( entries, fmt0->nPairs ) ) goto Exit; for ( i = 0; i < fmt0->nPairs; i++ ) @@ -3544,7 +3544,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c static FT_Error gx_kern_load_fmt1_subtable ( GX_Face face, FT_Stream stream, - GX_KerningSubtableHeader header, + GX_KerningSubtableHeader header, GX_KerningSubtableFormat1Body fmt1 ) { FT_Error error; @@ -3555,11 +3555,11 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c fmt1->values = NULL; state_table_pos = FT_STREAM_POS(); - if (( error = gx_face_load_StateTable ( face, stream, + if (( error = gx_face_load_StateTable ( face, stream, &fmt1->state_table, NULL, NULL ))) goto Exit; - + if ( FT_STREAM_SEEK( state_table_pos + GX_STATE_HEADER_ADVANCE ) ) goto Failure; if ( FT_READ_USHORT ( fmt1->valueTable ) ) @@ -3576,12 +3576,12 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c value_table_length = header->length + header->position; fmt1->nValues = value_table_length / sizeof (*(fmt1->values)); value_table_length = fmt1->nValues * sizeof (*(fmt1->values)); /* rounding */ - + if ( FT_NEW_ARRAY ( fmt1->values, fmt1->nValues ) ) goto Failure; if ( FT_FRAME_ENTER( value_table_length ) ) goto Failure; - + for ( i = 0; i < fmt1->nValues; i++ ) fmt1->values[i] = FT_GET_USHORT(); FT_FRAME_EXIT(); @@ -3608,8 +3608,8 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_Error error; FT_Memory memory = stream->memory; FT_Int i; - - const FT_Frame_Field kern_fmt2_class_table_fields[] = + + static const FT_Frame_Field kern_fmt2_class_table_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_KerningSubtableFormat2ClassTableRec @@ -3618,14 +3618,14 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_FRAME_USHORT ( nGlyphs ), FT_FRAME_END }; - + if ( FT_STREAM_SEEK ( pos ) ) goto Exit; - + if ( FT_STREAM_READ_FIELDS( kern_fmt2_class_table_fields, class_table ) ) goto Exit; - + if ( FT_NEW_ARRAY( class_table->classes, class_table->nGlyphs ) ) goto Exit; @@ -3654,7 +3654,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c static FT_Error gx_kern_load_fmt2_subtable ( GX_Face face, FT_Stream stream, - GX_KerningSubtableHeader header, + GX_KerningSubtableHeader header, GX_KerningSubtableFormat2Body fmt2 ) { FT_Error error; @@ -3662,10 +3662,10 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_ULong pos; FT_Int i; FT_Int max_value_index; - const FT_Frame_Field kern_fmt2_subtable_fields [] = + static const FT_Frame_Field kern_fmt2_subtable_fields [] = { #undef FT_STRUCTURE -#define FT_STRUCTURE GX_KerningSubtableFormat2BodyRec +#define FT_STRUCTURE GX_KerningSubtableFormat2BodyRec FT_FRAME_START( 8 ), FT_FRAME_USHORT ( rowWidth ), FT_FRAME_USHORT ( leftClassTable ), @@ -3674,25 +3674,25 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_FRAME_END }; - + fmt2->leftClass.classes = NULL; fmt2->rightClass.classes = NULL; fmt2->values = NULL; - + if ( FT_STREAM_READ_FIELDS( kern_fmt2_subtable_fields, fmt2 ) ) goto Exit; - + pos = header->position + fmt2->leftClassTable; - if ( ( error = gx_kern_load_fmt2_class_table ( face, stream, + if ( ( error = gx_kern_load_fmt2_class_table ( face, stream, pos, & fmt2->leftClass ) ) ) goto Exit; - + pos = header->position + fmt2->rightClassTable; - if ( ( error = gx_kern_load_fmt2_class_table ( face, stream, + if ( ( error = gx_kern_load_fmt2_class_table ( face, stream, pos, & fmt2->rightClass ) ) ) goto Failure_leftClass; - + pos = header->position + fmt2->array; if ( FT_STREAM_SEEK( pos ) ) goto Failure_rightClass; @@ -3725,7 +3725,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c static FT_Error gx_kern_load_fmt3_subtable ( GX_Face face, FT_Stream stream, - GX_KerningSubtableHeader header, + GX_KerningSubtableHeader header, GX_KerningSubtableFormat3Body fmt3 ) { FT_Error error; @@ -3734,12 +3734,12 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_FWord * kernValue; /* [kernValueCount] */ FT_Byte * leftClass; /* [glyphCount] */ FT_Byte * rightClass; /* [glyphCount] */ - FT_Byte * kernIndex; /* [leftClassCount * rightClassCount] */ + FT_Byte * kernIndex; /* [leftClassCount * rightClassCount] */ FT_ULong byte_count; - const FT_Frame_Field kern_fmt3_subtable_fields [] = + static const FT_Frame_Field kern_fmt3_subtable_fields [] = { #undef FT_STRUCTURE -#define FT_STRUCTURE GX_KerningSubtableFormat3BodyRec +#define FT_STRUCTURE GX_KerningSubtableFormat3BodyRec FT_FRAME_START ( 6 ), FT_FRAME_USHORT (glyphCount), FT_FRAME_BYTE (kernValueCount), @@ -3748,23 +3748,23 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_FRAME_BYTE (flags), FT_FRAME_END }; - + if ( FT_STREAM_READ_FIELDS( kern_fmt3_subtable_fields, fmt3 ) ) goto Exit; - - byte_count = sizeof(kernValue[0]) * fmt3->kernValueCount + + byte_count = sizeof(kernValue[0]) * fmt3->kernValueCount + sizeof(FT_Byte) * (fmt3->glyphCount + fmt3->glyphCount - + (fmt3->leftClassCount + + (fmt3->leftClassCount * fmt3->rightClassCount)); if ( FT_ALLOC ( kernValue , byte_count ) ) goto Exit; - + leftClass = (FT_Byte *)(kernValue + fmt3->kernValueCount); rightClass = leftClass+fmt3->glyphCount; kernIndex = rightClass+fmt3->glyphCount; - + if ( FT_FRAME_ENTER( byte_count ) ) goto Failure; for ( i = 0; i < fmt3->kernValueCount; i++ ) @@ -3775,7 +3775,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c rightClass[i] = FT_GET_BYTE(); for ( i = 0; i < fmt3->leftClassCount * fmt3->rightClassCount; i++ ) kernIndex[i] = FT_GET_BYTE(); - FT_FRAME_EXIT(); + FT_FRAME_EXIT(); fmt3->kernValue = kernValue; fmt3->leftClass = leftClass; fmt3->rightClass = rightClass; @@ -3802,8 +3802,8 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c } static FT_Error - gx_kern_load_subtable( GX_Face face, - FT_Stream stream, + gx_kern_load_subtable( GX_Face face, + FT_Stream stream, FT_ULong pos, GX_KerningSubtable subtable ) { @@ -3815,7 +3815,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c GX_KerningSubtableFormat1Body fmt1; GX_KerningSubtableFormat2Body fmt2; GX_KerningSubtableFormat3Body fmt3; - + if ( FT_STREAM_SEEK( pos ) ) goto Exit; if (( error = gx_kern_load_sutable_header ( face, @@ -3833,7 +3833,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c } \ subtable->body.fmt = fmt; \ } while (0) - + format = header->coverage&GX_KERN_COVERAGE_FORMAT_MASK; switch ( format ) { @@ -3853,7 +3853,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c Exit: return error; } - + static void gx_kern_free_subtable( FT_Memory memory, GX_KerningSubtable subtable ) @@ -3871,13 +3871,13 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c break; case GX_KERN_FMT_STATE_TABLE_FOR_CONTEXTUAL_KERNING: KERN_FMT_FREE(fmt1); - break; + break; case GX_KERN_FMT_SIMPLE_NXM_ARRAY_OF_KERNING_VALUES: KERN_FMT_FREE(fmt2); - break; + break; case GX_KERN_FMT_SIMPLE_NXM_ARRAY_OF_KERNING_INDICES: KERN_FMT_FREE(fmt3); - break; + break; } subtable->body.any = NULL; } @@ -3891,7 +3891,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_Memory memory = stream->memory; GX_KerningSubtable subtables; FT_ULong subtable_start_pos; - const FT_Frame_Field kern_fields[] = + static const FT_Frame_Field kern_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_KernRec @@ -3901,7 +3901,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_FRAME_END }; FT_Int i, j; - + /* FT_TRACE2(( "Kerning " )); */ if (( error = gx_table_init( &(kern->root), face, TTAG_kern, stream, (GX_Table_Done_Func)gx_kern_done) )) @@ -3917,12 +3917,12 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c if ( FT_NEW_ARRAY( subtables, kern->nTables ) ) goto Exit; - + subtable_start_pos = FT_STREAM_POS(); for ( i = 0; i < kern->nTables; i++ ) { - if ( ( error = gx_kern_load_subtable( face, - stream, + if ( ( error = gx_kern_load_subtable( face, + stream, subtable_start_pos, &subtables[i] ) ) ) goto Failure; @@ -3943,7 +3943,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_LOCAL_DEF ( void ) gx_kern_done( GX_Kern kern, FT_Memory memory ) - + { FT_Int i; @@ -3956,10 +3956,10 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c /****************************FVAR***********************************/ - static FT_Error gx_fvar_load_sfnt_instance ( GX_Face face, FT_Stream stream, + static FT_Error gx_fvar_load_sfnt_instance ( GX_Face face, FT_Stream stream, FT_UShort axis_count, GX_FontVariationsSFNTInstance instance ); - static void gx_fvar_free_sfnt_instance ( FT_Memory memory, + static void gx_fvar_free_sfnt_instance ( FT_Memory memory, GX_FontVariationsSFNTInstance instance ); FT_LOCAL ( FT_Error ) @@ -3970,11 +3970,11 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_Error error; FT_UShort i, j; FT_Memory memory = stream->memory; - - const FT_Frame_Field fvar_fields[] = + + static const FT_Frame_Field fvar_fields[] = { #undef FT_STRUCTURE -#define FT_STRUCTURE GX_FvarRec +#define FT_STRUCTURE GX_FvarRec FT_FRAME_START ( 14 ), FT_FRAME_LONG ( version ), FT_FRAME_USHORT ( offsetToData ), @@ -3986,7 +3986,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_FRAME_END }; - const FT_Frame_Field fvar_axis_fields[] = + static const FT_Frame_Field fvar_axis_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_FontVariationsSFNTVariationAxisRec @@ -3999,32 +3999,32 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_FRAME_USHORT( nameID ), FT_FRAME_END }; - + if (( error = gx_table_init( &(fvar->root), face, TTAG_fvar, stream, (GX_Table_Done_Func)gx_fvar_done) )) goto Failure; - + if ( FT_STREAM_READ_FIELDS( fvar_fields, fvar ) ) goto Failure; if ( FT_STREAM_SEEK( fvar->root.position + fvar->offsetToData ) ) goto Failure; - + if ( FT_NEW_ARRAY( fvar->axis, fvar->axisCount ) ) goto Failure; if ( FT_NEW_ARRAY( fvar->instance, fvar->instanceCount ) ) goto Failure; - + for ( i = 0; i < fvar->axisCount; i++ ) { if ( FT_STREAM_READ_FIELDS( fvar_axis_fields, &fvar->axis[i] ) ) goto Failure; } - + for ( i = 0; i < fvar->instanceCount; i++ ) { - if (( error = gx_fvar_load_sfnt_instance( face, + if (( error = gx_fvar_load_sfnt_instance( face, stream, fvar->axisCount, &fvar->instance[i]) )) @@ -4045,16 +4045,16 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c } static FT_Error - gx_fvar_load_sfnt_instance ( GX_Face face, - FT_Stream stream, + gx_fvar_load_sfnt_instance ( GX_Face face, + FT_Stream stream, FT_UShort axis_count, GX_FontVariationsSFNTInstance instance ) { FT_Error error; FT_UShort i; FT_Memory memory = stream->memory; - - const FT_Frame_Field fvar_sfnt_instance_fields[] = + + static const FT_Frame_Field fvar_sfnt_instance_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_FontVariationsSFNTInstanceRec @@ -4066,19 +4066,19 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c if (( FT_NEW_ARRAY( instance->coord, axis_count ) )) goto Failure; - - if ( FT_STREAM_READ_FIELDS( fvar_sfnt_instance_fields, + + if ( FT_STREAM_READ_FIELDS( fvar_sfnt_instance_fields, instance ) ) goto Failure; if ( FT_FRAME_ENTER ( axis_count * sizeof( FT_Fixed) ) ) goto Failure; - + for ( i = 0; i < axis_count; i++ ) instance->coord[i] = FT_GET_LONG(); - + FT_FRAME_EXIT(); - + return error; Failure: if ( instance->coord ) @@ -4086,7 +4086,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c return error; } static void - gx_fvar_free_sfnt_instance ( FT_Memory memory, + gx_fvar_free_sfnt_instance ( FT_Memory memory, GX_FontVariationsSFNTInstance instance ) { FT_FREE( instance->coord ); @@ -4097,7 +4097,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_Memory memory ) { FT_UShort i; - + for ( i = fvar->instanceCount; i > 0; i-- ) gx_fvar_free_sfnt_instance(memory, &fvar->instance[i - 1] ); @@ -4120,25 +4120,25 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c FT_Stream stream = lookup_data->stream; GX_LookupTable lookup_table = lookup_data->lookup_table; FT_Int table_tag = lookup_data->table_tag; - + FT_Memory memory = stream->memory; FT_Short value_offset = value->raw.s; FT_UShort segment_count = lastGlyph - firstGlyph + 1; FT_UShort * segment; - + FT_Int i; - + if ( table_tag ) { - if ( (error = face->goto_table( face, table_tag, stream, 0 )) || + if ( (error = face->goto_table( face, table_tag, stream, 0 )) || FT_STREAM_SEEK( FT_STREAM_POS() + value_offset ) ) goto Exit; } else { - if (FT_STREAM_SEEK( lookup_table->position + value_offset ) ) + if (FT_STREAM_SEEK( lookup_table->position + value_offset ) ) goto Exit; } @@ -4154,10 +4154,10 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c Exit: return error; Failure: - /* TODO + /* TODO -------------------------------------------------------------- - Other value->extra.wordS loaded before the visitation to this - value->extra.word must be freed if an error is occurred during + Other value->extra.wordS loaded before the visitation to this + value->extra.word must be freed if an error is occurred during traverse. */ FT_FREE(segment); return error; @@ -4177,7 +4177,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c value->extra.word = NULL; FT_FREE(segment); - return GX_Err_Ok; + return GX_Err_Ok; } static FT_Error @@ -4193,31 +4193,31 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c GX_LookupTable lookup_table; GX_LookupTable_FuncsRec funcs = GX_LOOKUP_TABLE_FUNC_ZERO; generic_lookup_table_cb_data_rec user_data = GENERIC_LOOKUP_TABLE_CB_DATA_ZERO; - + funcs.segment_array_func = generic_lookup_table_segment_array_loader; user_data.face = face; user_data.stream = stream; /* ----------------------------------------------------------------- - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING * This code is correct? - * In spec: "Sometimes they are 16-bit offsets from the start of + * In spec: "Sometimes they are 16-bit offsets from the start of * the table to the data. " The table? Is the table the lookup table * or a table that uses the lookup table? * Here I assume the table is the lookup table. * * The 11th chainSubtable in /Library/Fonts/GujaratiMT.ttf in MacOSX - * is format 4 lookup table; and it expects the table is the lookup + * is format 4 lookup table; and it expects the table is the lookup * table. * It seems that pfaedit uses lookup_table_offset + value_offset. * ----------------------------------------------------------------- */ /* user_data.table_tag = tag; */ user_data.table_tag = 0; - + if ( FT_NEW ( noncontextual_body ) ) goto Exit; lookup_table = &noncontextual_body->lookup_table; user_data.lookup_table = lookup_table; - if (( error = gx_face_load_LookupTable( face, stream, + if (( error = gx_face_load_LookupTable( face, stream, lookup_table ))) goto Failure; @@ -4303,11 +4303,11 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c } static FT_Error - gx_table_init(GX_Table table_info, + gx_table_init(GX_Table table_info, GX_Face face, FT_ULong tag, FT_Stream stream, GX_Table_Done_Func done_table) { FT_Error error; - if (( error = face->goto_table( face, tag, stream, + if (( error = face->goto_table( face, tag, stream, &table_info->length) )) return error; table_info->position = FT_STREAM_POS(); @@ -4321,7 +4321,7 @@ static void gx_morx_free_subtable( FT_Memory memory, GX_XMetamorphosisSubtable c { if ( table && table->done_table) table->done_table( table, memory ); - return FT_Err_Ok; + return FT_Err_Ok; } /* END */ diff --git a/src/gxlayout/gxlookuptbl.c b/src/gxlayout/gxlookuptbl.c index 4298caf04..865b7d8be 100644 --- a/src/gxlayout/gxlookuptbl.c +++ b/src/gxlayout/gxlookuptbl.c @@ -40,7 +40,7 @@ GX_BinSrchHeader header ) { FT_Error error; - const FT_Frame_Field fields[] = + static const FT_Frame_Field fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_BinSrchHeaderRec diff --git a/src/gxlayout/gxstatetbl.c b/src/gxlayout/gxstatetbl.c index 53dafefd8..148de9971 100644 --- a/src/gxlayout/gxstatetbl.c +++ b/src/gxlayout/gxstatetbl.c @@ -36,7 +36,7 @@ GX_StateHeader header ) { FT_Error error; - const FT_Frame_Field state_header_fields[] = + static const FT_Frame_Field state_header_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_StateHeaderRec @@ -60,8 +60,8 @@ FT_Error error; FT_Memory memory = stream->memory; FT_Byte * classArray; - FT_Int i; - const FT_Frame_Field class_subtable_fields[] = + FT_Int i; + static const FT_Frame_Field class_subtable_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_ClassSubtableRec @@ -69,13 +69,13 @@ FT_FRAME_USHORT ( firstGlyph ), FT_FRAME_USHORT ( nGlyphs ), FT_FRAME_END - }; - + }; + subtable->classArray = NULL; if ( FT_STREAM_SEEK(pos) ) goto Exit; - + if ( FT_STREAM_READ_FIELDS ( class_subtable_fields, subtable ) ) goto Exit; @@ -84,10 +84,10 @@ if ( FT_FRAME_ENTER( sizeof (classArray[0]) * subtable->nGlyphs ) ) goto Failure; - + for ( i = 0; i < subtable->nGlyphs; i++ ) classArray[i] = FT_GET_BYTE(); - + FT_FRAME_EXIT(); subtable->classArray = classArray; Exit: @@ -117,13 +117,13 @@ if ( FT_STREAM_SEEK(pos) ) goto Exit; - + if ( FT_FRAME_ENTER( sizeof (state_array[0]) * length ) ) goto Exit; for ( i = 0; i < length; i++ ) state_array[i] = FT_GET_BYTE(); - + FT_FRAME_EXIT(); Exit: return error; @@ -131,8 +131,8 @@ /* - gx_StateTable_load_entry_subtable I assume FUNCS is not NULL. Set any kind of dummy in the caller if - necessary. - To support both a state table and an extended state table, the type of nEntries + necessary. + To support both a state table and an extended state table, the type of nEntries is FT_ULong. */ static FT_Error gx_StateTable_load_entry_subtable ( GX_Face face, @@ -146,8 +146,8 @@ FT_Error error; FT_Memory memory = face->root.driver->root.memory; FT_ULong i, j; - - const FT_Frame_Field entry_subtable_fields[] = + + static const FT_Frame_Field entry_subtable_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_EntrySubtableRec @@ -155,7 +155,7 @@ FT_FRAME_USHORT ( newState ), FT_FRAME_USHORT ( flags ), FT_FRAME_END - }; + }; if ( FT_STREAM_SEEK( pos ) ) goto Exit; @@ -187,7 +187,7 @@ finalizer(memory, &entry_subtable[i], user); } - static FT_Error + static FT_Error gx_StateTable_Entry_default_loader ( GX_Face face, FT_Stream stream, GX_EntrySubtable entry_subtable, @@ -218,7 +218,7 @@ } return max_index; } - + FT_LOCAL_DEF ( FT_Error ) gx_face_load_StateTable ( GX_Face face, FT_Stream stream, @@ -242,14 +242,14 @@ state_table->state_array = NULL; state_table->entry_subtable = NULL; - + /* 1. Header */ header = &state_table->header; if (( error = gx_StateTable_load_header( face, stream, header ) )) goto Exit; - /* 2. class subtable */ + /* 2. class subtable */ pos = header->position + header->classTable; class_subtable = &state_table->class_subtable; if (( error = gx_StateTable_load_class_subtable( face, @@ -259,9 +259,9 @@ goto Exit; - /* 3. state array */ + /* 3. state array */ /* To calculate the length of stateArray, we assume - the order of fields placement is classTable, stateArray, + the order of fields placement is classTable, stateArray, entryTable */ FT_ASSERT( header->classTable < header->stateArray ); FT_ASSERT( header->stateArray < header->entryTable ); @@ -269,19 +269,19 @@ pos = header->position + header->stateArray; state_array_len = header->entryTable - header->stateArray; state_table->nStates = state_array_len / header->stateSize; - /* Calculate state_array_len again. + /* Calculate state_array_len again. state_array_len must be a multiple of header->stateSize. */ state_array_len = state_table->nStates * header->stateSize; if (( FT_NEW_ARRAY ( state_array, state_array_len ) )) goto Failure; - + if (( error = gx_StateTable_load_state_array( face, stream, pos, state_array_len, state_array ) )) goto Failure; - + /* 4. entry subtable */ if ( funcs ) { @@ -289,7 +289,7 @@ funcs->loader = gx_StateTable_Entry_default_loader; if (! funcs->finalizer ) funcs->finalizer = gx_StateTable_Entry_default_finalizer; - } + } else funcs = &default_funcs; @@ -298,10 +298,10 @@ which starts from 0. By adding 1 to the max index, get the length of the array. */ state_table->nEntries = 1+ gx_StateTable_find_state_array_max_index(state_array_len, state_array); - + if (( FT_NEW_ARRAY( entry_subtable, state_table->nEntries) )) goto Failure; - if (( error = gx_StateTable_load_entry_subtable( face, + if (( error = gx_StateTable_load_entry_subtable( face, stream, pos, state_table->nEntries, @@ -331,7 +331,7 @@ { if ( finalizer == NULL ) finalizer = gx_StateTable_Entry_default_finalizer; - gx_StateTable_free_entry_subtable ( memory, + gx_StateTable_free_entry_subtable ( memory, state_table->nEntries, state_table->entry_subtable, finalizer, @@ -374,7 +374,7 @@ { return gx_EntrySubtable_traverse( state_table->entry_subtable, state_table->nEntries, - action, + action, user ); } #endif /* 0 */ @@ -386,11 +386,11 @@ GX_ClassSubtable class_subtable; FT_Byte class_code; FT_UShort first_glyph, last_glyph; - + class_subtable = &state_table->class_subtable; first_glyph = class_subtable->firstGlyph; last_glyph = first_glyph + class_subtable->nGlyphs; - + if ( glyph == GX_DELETED_GLYPH_INDEX ) class_code = GX_CLASS_DELETED_GLYPH; else if ( ( first_glyph <= glyph ) && ( glyph < last_glyph ) ) @@ -399,7 +399,7 @@ class_code = GX_CLASS_OUT_OF_BOUNDS; return class_code; } - + FT_LOCAL_DEF ( GX_EntrySubtable ) gx_StateTable_get_entry_subtable ( GX_StateTable state_table, FT_UShort current_state, @@ -410,7 +410,7 @@ GX_EntrySubtable entry_subtable = state_table->entry_subtable; FT_Byte * state_array_for_current_state; FT_Byte entry_index; - + state_array_for_current_state = &state_array[current_state - header->stateArray]; entry_index = state_array_for_current_state[class_code]; return &entry_subtable[entry_index]; @@ -420,8 +420,8 @@ * Extended State Table */ -#define gx_XStateTable_load_entry_subtable gx_StateTable_load_entry_subtable -#define gx_XStateTable_free_entry_subtable gx_StateTable_free_entry_subtable +#define gx_XStateTable_load_entry_subtable gx_StateTable_load_entry_subtable +#define gx_XStateTable_free_entry_subtable gx_StateTable_free_entry_subtable #define gx_XStateTable_Entry_default_loader gx_StateTable_Entry_default_loader #define gx_XStateTable_Entry_default_finalizer gx_StateTable_Entry_default_finalizer @@ -433,7 +433,7 @@ GX_XStateHeader header ) { FT_Error error; - const FT_Frame_Field xstate_header_fields[] = + static const FT_Frame_Field xstate_header_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE GX_XStateHeaderRec @@ -460,13 +460,13 @@ if ( FT_STREAM_SEEK(pos) ) goto Exit; - + if ( FT_FRAME_ENTER( sizeof (state_array[0]) * length ) ) goto Exit; for ( i = 0; i < length; i++ ) state_array[i] = FT_GET_USHORT(); - + FT_FRAME_EXIT(); Exit: return error; @@ -509,23 +509,23 @@ FT_Short value_offset = value->raw.s; FT_UShort segment_count = lastGlyph - firstGlyph + 1; FT_UShort * segment; - + FT_Int i; /* ----------------------------------------------------------------- - * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING * This code is correct? - * In spec: "Sometimes they are 16-bit offsets from the start of + * In spec: "Sometimes they are 16-bit offsets from the start of * the table to the data. " The table? Is the table the lookup table * or a table that uses the lookup table? * Here I assume the table is the table that uses the lookup table. - * However, I have no conviction. + * However, I have no conviction. * It seems that pfaedit uses lookup_table_offset + value_offset. * ----------------------------------------------------------------- */ FT_ASSERT(lookup_table->position + value_offset < lookup_data->table_end); - if (FT_STREAM_SEEK( lookup_table->position + value_offset ) ) + if (FT_STREAM_SEEK( lookup_table->position + value_offset ) ) goto Exit; - + if ( FT_NEW_ARRAY(segment, segment_count ) ) goto Exit; @@ -539,8 +539,8 @@ return error; Failure: /* TODO - Other value->extra.wordS loaded before the visitation to this - value->extra.word must be freed if an error is occurred during + Other value->extra.wordS loaded before the visitation to this + value->extra.word must be freed if an error is occurred during traverse. */ FT_FREE(segment); return error; @@ -572,25 +572,25 @@ state_table->state_array = NULL; state_table->entry_subtable = NULL; - + /* 1. Header */ header = &state_table->header; if (( error = gx_XStateTable_load_header( face, stream, header ) )) goto Exit; - /* 2. class subtable */ + /* 2. class subtable */ pos = header->position + header->classTableOffset; if ( FT_STREAM_SEEK( pos ) ) goto Exit; - if (( error = gx_face_load_LookupTable( face, - stream, + if (( error = gx_face_load_LookupTable( face, + stream, &state_table->class_subtable ) )) goto Exit; if ( state_table->class_subtable.format == GX_LOOKUPTABLE_SEGMENT_ARRAY ) { - + lookup_table_cb_data.stream = stream; lookup_table_cb_data.lookup_table = &state_table->class_subtable; lookup_table_cb_data.table_end = header->position + header->stateArrayOffset; @@ -599,24 +599,24 @@ & lookup_table_cb_data ) )) goto Failure; } - - /* 3. state array */ + + /* 3. state array */ /* To calculate the length of stateArray, we assume - the order of fields placement is classTable, stateArray, + the order of fields placement is classTable, stateArray, entryTable */ FT_ASSERT( header->classTableOffset < header->stateArrayOffset ); FT_ASSERT( header->stateArrayOffset < header->entryTableOffset ); - + pos = header->position + header->stateArrayOffset; - state_array_len = (header->entryTableOffset - header->stateArrayOffset) / sizeof( state_array[0] ); + state_array_len = (header->entryTableOffset - header->stateArrayOffset) / sizeof( state_array[0] ); state_table->nStates = state_array_len / header->nClasses; - /* Calculate state_array_len again. - state_array_len must be a multiple of header->nClasses. */ + /* Calculate state_array_len again. + state_array_len must be a multiple of header->nClasses. */ state_array_len = state_table->nStates * header->nClasses; if (( FT_NEW_ARRAY ( state_array, state_array_len ) )) goto Failure; - + if (( error = gx_XStateTable_load_state_array( face, stream, pos, @@ -631,7 +631,7 @@ funcs->loader = gx_XStateTable_Entry_default_loader; if (! funcs->finalizer ) funcs->finalizer = gx_XStateTable_Entry_default_finalizer; - } + } else funcs = &default_XStateTable_funcs; @@ -640,7 +640,7 @@ state_array ); if (( FT_NEW_ARRAY( entry_subtable, state_table->nEntries) )) goto Failure; - if (( error = gx_XStateTable_load_entry_subtable( face, + if (( error = gx_XStateTable_load_entry_subtable( face, stream, pos, state_table->nEntries, @@ -668,8 +668,8 @@ { return gx_EntrySubtable_traverse( state_table->entry_subtable, state_table->nEntries, - action, - user ); + action, + user ); } static FT_Error @@ -687,7 +687,7 @@ value->extra.word = NULL; FT_FREE(segment); - return GX_Err_Ok; + return GX_Err_Ok; } FT_LOCAL_DEF ( void ) @@ -699,10 +699,10 @@ GX_LookupTable_FuncsRec lookup_table_funcs = GX_LOOKUP_TABLE_FUNC_ZERO; lookup_table_funcs.segment_array_func = gx_XStateTable_LookupTable_segment_array_finalizer; - + if ( finalizer == NULL ) finalizer = gx_StateTable_Entry_default_finalizer; - gx_XStateTable_free_entry_subtable ( memory, + gx_XStateTable_free_entry_subtable ( memory, state_table->nEntries, state_table->entry_subtable, finalizer, @@ -713,7 +713,7 @@ FT_FREE( state_table->state_array ); state_table->state_array = NULL; - + if ( state_table->class_subtable.format == GX_LOOKUPTABLE_SEGMENT_ARRAY ) gx_LookupTable_traverse_low( & state_table->class_subtable, &lookup_table_funcs, @@ -728,11 +728,11 @@ GX_LookupTable class_subtable; GX_LookupResultRec result; FT_UShort class_code; - + class_subtable = &state_table->class_subtable; result = gx_LookupTable_lookup ( class_subtable, glyph ); - + if ( result.value == NULL ) class_code = GX_CLASS_OUT_OF_BOUNDS; else if ( result.firstGlyph == GX_LOOKUP_RESULT_NO_FIRST_GLYPH ) @@ -747,12 +747,12 @@ FT_UShort current_state, FT_UShort class_code ) { - GX_XStateHeader header = &state_table->header; + GX_XStateHeader header = &state_table->header; FT_UShort * state_array = state_table->state_array; FT_UShort * state_array_for_current_state; FT_UShort entry_index; GX_EntrySubtable entry_subtable; - + FT_ASSERT( current_state < state_table->nStates ); FT_ASSERT( class_code < header->nClasses ); state_array_for_current_state = &state_array[current_state * header->nClasses]; diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c index 937cd0207..0a58188d6 100644 --- a/src/sfnt/ttload.c +++ b/src/sfnt/ttload.c @@ -669,7 +669,7 @@ FT_Error error; TT_MaxProfile* maxProfile = &face->max_profile; - const FT_Frame_Field maxp_fields[] = + static const FT_Frame_Field maxp_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE TT_MaxProfile @@ -680,7 +680,7 @@ FT_FRAME_END }; - const FT_Frame_Field maxp_fields_extra[] = + static const FT_Frame_Field maxp_fields_extra[] = { FT_FRAME_START( 26 ), FT_FRAME_USHORT( maxPoints ), @@ -952,7 +952,7 @@ FT_Error error; TT_HoriHeader* header; - const FT_Frame_Field metrics_header_fields[] = + static const FT_Frame_Field metrics_header_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE TT_HoriHeader @@ -1277,7 +1277,7 @@ FT_Error error; TT_OS2* os2; - const FT_Frame_Field os2_fields[] = + static const FT_Frame_Field os2_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE TT_OS2 @@ -1329,7 +1329,7 @@ FT_FRAME_END }; - const FT_Frame_Field os2_fields_extra[] = + static const FT_Frame_Field os2_fields_extra[] = { FT_FRAME_START( 8 ), FT_FRAME_ULONG( ulCodePageRange1 ), @@ -1337,7 +1337,7 @@ FT_FRAME_END }; - const FT_Frame_Field os2_fields_extra2[] = + static const FT_Frame_Field os2_fields_extra2[] = { FT_FRAME_START( 10 ), FT_FRAME_SHORT ( sxHeight ), diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c index bb6f227a7..10ef39cda 100644 --- a/src/sfnt/ttsbit.c +++ b/src/sfnt/ttsbit.c @@ -185,7 +185,7 @@ } - const FT_Frame_Field sbit_metrics_fields[] = + static const FT_Frame_Field sbit_metrics_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE TT_SBit_MetricsRec @@ -400,7 +400,7 @@ FT_ULong num_strikes; FT_ULong table_base; - const FT_Frame_Field sbit_line_metrics_fields[] = + static const FT_Frame_Field sbit_line_metrics_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE TT_SBit_LineMetricsRec @@ -423,7 +423,7 @@ FT_FRAME_END }; - const FT_Frame_Field strike_start_fields[] = + static const FT_Frame_Field strike_start_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE TT_SBit_StrikeRec @@ -436,7 +436,7 @@ FT_FRAME_END }; - const FT_Frame_Field strike_end_fields[] = + static const FT_Frame_Field strike_end_fields[] = { /* no FT_FRAME_START */ FT_FRAME_USHORT( start_glyph ), @@ -860,7 +860,7 @@ { TT_SBit_SmallMetricsRec smetrics; - const FT_Frame_Field sbit_small_metrics_fields[] = + static const FT_Frame_Field sbit_small_metrics_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE TT_SBit_SmallMetricsRec