@@ -249,9 +249,9 @@ fn apply_simple_kerning<T: SimpleKerning>(c: &mut AatApplyContext, subtable: &Su
249249 } else {
250250 let kern1 = kern >> 1 ;
251251 let kern2 = kern - kern1;
252- pos[ i] . x_advance += kern1;
253- pos[ j] . x_advance += kern2;
254- pos[ j] . x_offset += kern2;
252+ pos[ i] . x_advance = pos [ i ] . x_advance . saturating_add ( kern1) ;
253+ pos[ j] . x_advance = pos [ j ] . x_advance . saturating_add ( kern2) ;
254+ pos[ j] . x_offset = pos [ j ] . x_offset . saturating_add ( kern2) ;
255255 }
256256 } else {
257257 if cross_stream {
@@ -260,9 +260,9 @@ fn apply_simple_kerning<T: SimpleKerning>(c: &mut AatApplyContext, subtable: &Su
260260 } else {
261261 let kern1 = kern >> 1 ;
262262 let kern2 = kern - kern1;
263- pos[ i] . y_advance += kern1;
264- pos[ j] . y_advance += kern2;
265- pos[ j] . y_offset += kern2;
263+ pos[ i] . y_advance = pos [ i ] . y_advance . saturating_add ( kern1) ;
264+ pos[ j] . y_advance = pos [ j ] . y_advance . saturating_add ( kern2) ;
265+ pos[ j] . y_offset = pos [ j ] . y_offset . saturating_add ( kern2) ;
266266 }
267267 }
268268
@@ -573,12 +573,12 @@ impl StateTableDriver<Subtable1<'_>, BigEndian<u16>> for Driver1 {
573573 pos. set_attach_chain ( 0 ) ;
574574 pos. y_offset = 0 ;
575575 } else if pos. attach_type ( ) != 0 {
576- pos. y_offset += scaled_v;
576+ pos. y_offset = pos . y_offset . saturating_add ( scaled_v) ;
577577 has_gpos_attachment = true ;
578578 }
579579 } else if glyph_mask & c. plan . kern_mask != 0 {
580- pos. x_advance += scaled_v;
581- pos. x_offset += scaled_v;
580+ pos. x_advance = pos . x_advance . saturating_add ( scaled_v) ;
581+ pos. x_offset = pos . x_offset . saturating_add ( scaled_v) ;
582582 }
583583 } else {
584584 if has_cross_stream {
@@ -588,13 +588,13 @@ impl StateTableDriver<Subtable1<'_>, BigEndian<u16>> for Driver1 {
588588 pos. set_attach_chain ( 0 ) ;
589589 pos. x_offset = 0 ;
590590 } else if pos. attach_type ( ) != 0 {
591- pos. x_offset += scaled_v;
591+ pos. x_offset = pos . x_offset . saturating_add ( scaled_v) ;
592592 has_gpos_attachment = true ;
593593 }
594594 } else if glyph_mask & c. plan . kern_mask != 0 {
595595 if pos. y_offset == 0 {
596- pos. y_advance += scaled_v;
597- pos. y_offset += scaled_v;
596+ pos. y_advance = pos . y_advance . saturating_add ( scaled_v) ;
597+ pos. y_offset = pos . y_offset . saturating_add ( scaled_v) ;
598598 }
599599 }
600600 }
0 commit comments