diff --git a/src/harfbuzz-gpos.c b/src/harfbuzz-gpos.c index 0b1ba5b..bd9f34a 100644 --- a/src/harfbuzz-gpos.c +++ b/src/harfbuzz-gpos.c @@ -6052,6 +6052,7 @@ HB_Error HB_GPOS_Apply_String( HB_Font font, HB_Error error, retError = HB_Err_Not_Covered; GPOS_Instance gpi; int i, j, lookup_count, num_features; + int *lookup_enabled; if ( !font || !gpos || !buffer ) return ERR(HB_Err_Invalid_Argument); @@ -6067,6 +6068,8 @@ HB_Error HB_GPOS_Apply_String( HB_Font font, lookup_count = gpos->LookupList.LookupCount; num_features = gpos->FeatureList.ApplyCount; + + lookup_enabled = calloc(sizeof(int), lookup_count); if ( num_features ) { @@ -6087,18 +6090,31 @@ HB_Error HB_GPOS_Apply_String( HB_Font font, /* Skip nonexistant lookups */ if (lookup_index >= lookup_count) continue; - - error = GPOS_Do_String_Lookup( &gpi, lookup_index, buffer ); + + lookup_enabled[lookup_index] = 1; + } + } + + for ( i = 0; i < lookup_count; i++ ) + { + if ( lookup_enabled[i] == 1 ) + { + error = GPOS_Do_String_Lookup( &gpi, i, buffer ); if ( error ) { if ( error != HB_Err_Not_Covered ) + { + free( lookup_enabled ); return error; + } } else retError = error; } } + free( lookup_enabled ); + if ( num_features ) { error = Position_CursiveChain ( buffer ); diff --git a/src/harfbuzz-gsub.c b/src/harfbuzz-gsub.c index a5439a5..dd17de4 100644 --- a/src/harfbuzz-gsub.c +++ b/src/harfbuzz-gsub.c @@ -4310,6 +4310,7 @@ HB_Error HB_GSUB_Apply_String( HB_GSUBHeader* gsub, { HB_Error error, retError = HB_Err_Not_Covered; int i, j, lookup_count, num_features; + int *lookup_enabled; if ( !gsub || !buffer) @@ -4320,7 +4321,10 @@ HB_Error HB_GSUB_Apply_String( HB_GSUBHeader* gsub, lookup_count = gsub->LookupList.LookupCount; num_features = gsub->FeatureList.ApplyCount; + + lookup_enabled = calloc(sizeof(int), lookup_count); + for ( i = 0; i < num_features; i++) { HB_UShort feature_index = gsub->FeatureList.ApplyOrder[i]; @@ -4331,19 +4335,30 @@ HB_Error HB_GSUB_Apply_String( HB_GSUBHeader* gsub, HB_UShort lookup_index = feature.LookupListIndex[j]; /* Skip nonexistant lookups */ - if (lookup_index >= lookup_count) + if ( lookup_index >= lookup_count ) continue; - - error = GSUB_Do_String_Lookup( gsub, lookup_index, buffer ); + + lookup_enabled[lookup_index] = 1; + } + } + + for ( i = 0; i < lookup_count; i++) + { + if ( lookup_enabled[i] == 1 ) + { + error = GSUB_Do_String_Lookup( gsub, i, buffer ); if ( error ) { if ( error != HB_Err_Not_Covered ) + free( lookup_enabled ); return error; } else retError = error; } } + + free( lookup_enabled ); error = retError;