date: 2002/09/26 08:40:00; author: werner; state: Exp; lines: +17 -7 Updating GSUB and GPOS support to the forthcoming OpenType 1.4 specification: Backtracking is *not* done in logical order. Index: ftxgpos.c =================================================================== RCS file: /cvs/freetype/freetype/lib/extend/ftxgpos.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -p -r1.16 -r1.17 --- ftxgpos.c 2002/01/19 00:23:23 1.16 +++ ftxgpos.c 2002/09/26 08:40:00 1.17 @@ -4737,7 +4737,8 @@ /* backtrack and lookahead data can be optional */ cur_offset = FILE_Pos(); - if ( backtrack_offset != base_offset ) { + if ( backtrack_offset != base_offset ) + { if ( FILE_Seek( backtrack_offset ) || ( error = Load_ClassDefinition( &ccpf2->BacktrackClassDef, count, input ) ) != TT_Err_Ok ) @@ -4747,7 +4748,8 @@ ( error = Load_ClassDefinition( &ccpf2->InputClassDef, count, input ) ) != TT_Err_Ok ) goto Fail4; - if ( lookahead_offset != base_offset ) { + if ( lookahead_offset != base_offset ) + { if ( FILE_Seek( lookahead_offset ) || ( error = Load_ClassDefinition( &ccpf2->LookaheadClassDef, count, input ) ) != TT_Err_Ok ) @@ -5164,7 +5166,7 @@ curr_pos = 0; s_in = &in->string[curr_pos]; - for ( i = bgc, j = in->pos - 1; i > 0; i--, j-- ) + for ( i = 0, j = in->pos - 1; i < bgc; i++, j-- ) { while ( CHECK_Property( gdef, s_in[j], flags, &property ) ) { @@ -5177,11 +5179,21 @@ break; } - if ( s_in[j] != curr_cpr.Backtrack[i - 1] ) + /* In OpenType 1.3, it is undefined whether the offsets of + backtrack glyphs is in logical order or not. Version 1.4 + will clarify this: + + Logical order - a b c d e f g h i j + i + Input offsets - 0 1 + Backtrack offsets - 3 2 1 0 + Lookahead offsets - 0 1 2 3 */ + + if ( s_in[j] != curr_cpr.Backtrack[i] ) break; } - if ( i != 0 ) + if ( i != bgc ) continue; } @@ -5364,7 +5376,7 @@ known_backtrack_classes = i; } - if ( bc[bgc - 1 - i] != backtrack_classes[i] ) + if ( bc[i] != backtrack_classes[i] ) break; } @@ -5512,7 +5524,7 @@ s_in = &in->string[curr_pos]; bc = ccpf3->BacktrackCoverage; - for ( i = bgc, j = in->pos - 1; i > 0; i--, j-- ) + for ( i = 0, j = in->pos - 1; i < bgc; i++, j-- ) { while ( CHECK_Property( gdef, s_in[j], flags, &property ) ) { @@ -5525,7 +5537,7 @@ return TTO_Err_Not_Covered; } - error = Coverage_Index( &bc[i - 1], s_in[j], &index ); + error = Coverage_Index( &bc[i], s_in[j], &index ); if ( error ) return error; } @@ -5555,8 +5567,8 @@ return error; } - /* we are starting for lookahead glyphs right after the last context - glyph */ + /* we are starting to check for lookahead glyphs right after the + last context glyph */ curr_pos = j; s_in = &in->string[curr_pos]; Index: ftxgsub.c =================================================================== RCS file: /cvs/freetype/freetype/lib/extend/ftxgsub.c,v retrieving revision 1.46 retrieving revision 1.47 diff -u -p -r1.46 -r1.47 --- ftxgsub.c 2002/01/19 00:23:23 1.46 +++ ftxgsub.c 2002/09/26 08:40:00 1.47 @@ -3387,13 +3387,13 @@ if ( bgc ) { - /* Since we don't know in advance the number of glyphs to inspect, + /* since we don't know in advance the number of glyphs to inspect, we search backwards for matches in the backtrack glyph array */ curr_pos = 0; s_in = &in->string[curr_pos]; - for ( i = bgc, j = in->pos - 1; i > 0; i--, j-- ) + for ( i = 0, j = in->pos - 1; i < bgc; i++, j-- ) { while ( CHECK_Property( gdef, s_in[j], flags, &property ) ) { @@ -3406,11 +3406,21 @@ break; } - if ( s_in[j] != curr_csr.Backtrack[i - 1] ) + /* In OpenType 1.3, it is undefined whether the offsets of + backtrack glyphs is in logical order or not. Version 1.4 + will clarify this: + + Logical order - a b c d e f g h i j + i + Input offsets - 0 1 + Backtrack offsets - 3 2 1 0 + Lookahead offsets - 0 1 2 3 */ + + if ( s_in[j] != curr_csr.Backtrack[i] ) break; } - if ( i != 0 ) + if ( i != bgc ) continue; } @@ -3592,7 +3602,7 @@ known_backtrack_classes = i; } - if ( bc[bgc - 1 - i] != backtrack_classes[i] ) + if ( bc[i] != backtrack_classes[i] ) break; } @@ -3739,7 +3749,7 @@ s_in = &in->string[curr_pos]; bc = ccsf3->BacktrackCoverage; - for ( i = bgc, j = in->pos - 1; i > 0; i--, j-- ) + for ( i = 0, j = in->pos - 1; i < bgc; i++, j-- ) { while ( CHECK_Property( gdef, s_in[j], flags, &property ) ) { @@ -3752,7 +3762,7 @@ return TTO_Err_Not_Covered; } - error = Coverage_Index( &bc[i - 1], s_in[j], &index ); + error = Coverage_Index( &bc[i], s_in[j], &index ); if ( error ) return error; }