@@ -183,64 +183,63 @@ impl Apply for PairAdjustment<'_> {
183
183
let second_glyph_index = iter. index ( ) ;
184
184
let second_glyph = ctx. buffer . info [ second_glyph_index] . as_glyph ( ) ;
185
185
186
- let finish = |ctx : & mut ApplyContext , len2 | {
186
+ let finish = |ctx : & mut ApplyContext , has_record2 | {
187
187
ctx. buffer . idx = second_glyph_index;
188
188
189
- if len2 != 0 {
189
+ if has_record2 {
190
190
ctx. buffer . idx += 1 ;
191
191
}
192
192
193
193
Some ( ( ) )
194
194
} ;
195
195
196
- let boring = |ctx : & mut ApplyContext , len2 | {
196
+ let boring = |ctx : & mut ApplyContext , has_record2 | {
197
197
ctx. buffer
198
198
. unsafe_to_concat ( Some ( ctx. buffer . idx ) , Some ( second_glyph_index + 1 ) ) ;
199
- finish ( ctx, len2 )
199
+ finish ( ctx, has_record2 )
200
200
} ;
201
201
202
- let success = |ctx : & mut ApplyContext , flag1, flag2, len2 | {
202
+ let success = |ctx : & mut ApplyContext , flag1, flag2, has_record2 | {
203
203
if flag1 || flag2 {
204
204
ctx. buffer
205
205
. unsafe_to_break ( Some ( ctx. buffer . idx ) , Some ( second_glyph_index + 1 ) ) ;
206
- finish ( ctx, len2 )
206
+ finish ( ctx, has_record2 )
207
207
} else {
208
- boring ( ctx, len2 )
208
+ boring ( ctx, has_record2 )
209
209
}
210
210
} ;
211
211
212
- let bail = |ctx : & mut ApplyContext , records : ( ValueRecord , ValueRecord ) , len2 | {
212
+ let bail = |ctx : & mut ApplyContext , records : ( ValueRecord , ValueRecord ) | {
213
213
let flag1 = records. 0 . apply ( ctx, ctx. buffer . idx ) ;
214
214
let flag2 = records. 1 . apply ( ctx, second_glyph_index) ;
215
215
216
- success ( ctx, flag1, flag2, len2)
216
+ let has_record2 = !records. 1 . is_empty ( ) ;
217
+ success ( ctx, flag1, flag2, has_record2)
217
218
} ;
218
219
219
- let ( records, len2) = match self {
220
- Self :: Format1 { sets, .. } => (
221
- sets. get ( first_glyph_coverage_index) ?. get ( second_glyph) ?,
222
- sets. value_format_flags ( ) . 1 . len ( ) ,
223
- ) ,
220
+ let records = match self {
221
+ Self :: Format1 { sets, .. } => {
222
+ sets. get ( first_glyph_coverage_index) ?. get ( second_glyph) ?
223
+ }
224
224
Self :: Format2 {
225
225
classes, matrix, ..
226
226
} => {
227
227
let classes = ( classes. 0 . get ( first_glyph) , classes. 1 . get ( second_glyph) ) ;
228
228
229
- if classes. 0 >= matrix. counts ( ) . 0 || classes. 1 >= matrix. counts ( ) . 1 {
230
- ctx. buffer
231
- . unsafe_to_concat ( Some ( ctx. buffer . idx ) , Some ( iter. index ( ) + 1 ) ) ;
232
- return None ;
233
- }
234
-
235
- let records = matrix. get ( classes) ?;
236
- let flags = matrix. value_format_flags ( ) ;
237
- let len2 = flags. 1 . len ( ) ;
229
+ let records = match matrix. get ( classes) {
230
+ Some ( v) => v,
231
+ None => {
232
+ ctx. buffer
233
+ . unsafe_to_concat ( Some ( ctx. buffer . idx ) , Some ( iter. index ( ) + 1 ) ) ;
234
+ return None ;
235
+ }
236
+ } ;
238
237
239
- return bail ( ctx, records, len2 ) ;
238
+ return bail ( ctx, records) ;
240
239
}
241
240
} ;
242
241
243
- bail ( ctx, records, len2 )
242
+ bail ( ctx, records)
244
243
}
245
244
}
246
245
@@ -545,11 +544,23 @@ impl Apply for MarkToMarkAdjustment<'_> {
545
544
}
546
545
547
546
trait ValueRecordExt {
547
+ fn is_empty ( & self ) -> bool ;
548
548
fn apply ( & self , ctx : & mut ApplyContext , idx : usize ) -> bool ;
549
549
fn apply_to_pos ( & self , ctx : & mut ApplyContext , pos : & mut GlyphPosition ) -> bool ;
550
550
}
551
551
552
552
impl ValueRecordExt for ValueRecord < ' _ > {
553
+ fn is_empty ( & self ) -> bool {
554
+ self . x_placement == 0
555
+ && self . y_placement == 0
556
+ && self . x_advance == 0
557
+ && self . y_advance == 0
558
+ && self . x_placement_device . is_none ( )
559
+ && self . y_placement_device . is_none ( )
560
+ && self . x_advance_device . is_none ( )
561
+ && self . y_advance_device . is_none ( )
562
+ }
563
+
553
564
fn apply ( & self , ctx : & mut ApplyContext , idx : usize ) -> bool {
554
565
let mut pos = ctx. buffer . pos [ idx] ;
555
566
let worked = self . apply_to_pos ( ctx, & mut pos) ;
0 commit comments