@@ -236,6 +236,7 @@ impl ShapedText {
236236 item : & Segment ,
237237 options : & ShapeOptions < ' _ > ,
238238 char_info : & [ CharInfo ] ,
239+ char_style_indices : & [ u16 ] ,
239240 font : & FontInstance ,
240241 glyph_buffer : & harfrust:: GlyphBuffer ,
241242 normalized_coords : & [ harfrust:: NormalizedCoord ] ,
@@ -318,7 +319,7 @@ impl ShapedText {
318319 for ( ( ( byte_offset, ch) , info) , style_index) in text[ range. byte_range . clone ( ) ]
319320 . char_indices ( )
320321 . zip ( & char_info[ range. char_range . clone ( ) ] )
321- . zip ( & options . char_style_indices [ range. char_range . clone ( ) ] )
322+ . zip ( & char_style_indices[ range. char_range . clone ( ) ] )
322323 {
323324 self . characters . push ( Character {
324325 text_byte_start : ( range. byte_range . start + byte_offset) as u32 ,
@@ -340,7 +341,6 @@ impl ShapedText {
340341 scale_factor,
341342 glyph_infos. iter ( ) ,
342343 glyph_positions. iter ( ) ,
343- & options. char_style_indices [ range. char_range . clone ( ) ] ,
344344 & self . characters ,
345345 characters_start,
346346 ) ;
@@ -351,7 +351,6 @@ impl ShapedText {
351351 scale_factor,
352352 glyph_infos. iter ( ) . rev ( ) ,
353353 glyph_positions. iter ( ) . rev ( ) ,
354- & options. char_style_indices [ range. char_range . clone ( ) ] ,
355354 & self . characters ,
356355 characters_start,
357356 ) ;
@@ -429,7 +428,6 @@ pub struct ShapedRun {
429428/// * `glyph_infos` - `HarfRust` glyph information in logical order (i.e., reversed for RTL runs).
430429/// * `glyph_positions` - `HarfRust` glyph positioning data in logical order (i.e., reversed for RTL
431430/// runs).
432- /// * `char_style_indices` - The run's slice of per-character style indices, indexed by cluster ID.
433431/// * `characters` must contain the shaped characters whose clusters we're now processing, starting at
434432/// index `characters_start`.
435433/// * `characters_start` - See `characters`.
@@ -439,7 +437,6 @@ fn process_shaped_clusters<'a>(
439437 scale_factor : f32 ,
440438 glyph_infos : impl Iterator < Item = & ' a harfrust:: GlyphInfo > ,
441439 glyph_positions : impl Iterator < Item = & ' a harfrust:: GlyphPosition > ,
442- char_style_indices : & [ u16 ] ,
443440 characters : & [ Character ] ,
444441 characters_start : usize ,
445442) {
@@ -457,7 +454,6 @@ fn process_shaped_clusters<'a>(
457454 fn flush (
458455 cluster : & mut Cluster ,
459456 char_end : usize ,
460- style_index : u16 ,
461457 characters : & [ Character ] ,
462458 shaped_clusters : & mut Vec < ShapedCluster > ,
463459 ) {
@@ -479,7 +475,7 @@ fn process_shaped_clusters<'a>(
479475
480476 shaped_clusters. push ( ShapedCluster {
481477 chars_range : ( cluster. characters_start as u32 , char_end as u32 ) ,
482- style_index,
478+ style_index : first_character . style_index ,
483479 flags : ShapedClusterFlags :: new ( glyph_len)
484480 . with_grapheme_start ( first_character. grapheme_start )
485481 // TODO: fill with actual shaping data (`parley` currently just ignores this)
@@ -502,14 +498,7 @@ fn process_shaped_clusters<'a>(
502498 for ( glyph_info, glyph_pos) in glyph_infos. zip ( glyph_positions) {
503499 if glyph_info. cluster != cluster. id {
504500 let char_end = characters_start + glyph_info. cluster as usize ;
505- let style_index = char_style_indices[ cluster. id as usize ] ;
506- flush (
507- & mut cluster,
508- char_end,
509- style_index,
510- characters,
511- shaped_clusters,
512- ) ;
501+ flush ( & mut cluster, char_end, characters, shaped_clusters) ;
513502
514503 cluster = Cluster {
515504 id : glyph_info. cluster ,
@@ -542,14 +531,7 @@ fn process_shaped_clusters<'a>(
542531 }
543532
544533 // Flush the final cluster.
545- let style_index = char_style_indices[ cluster. id as usize ] ;
546- flush (
547- & mut cluster,
548- characters. len ( ) ,
549- style_index,
550- characters,
551- shaped_clusters,
552- ) ;
534+ flush ( & mut cluster, characters. len ( ) , characters, shaped_clusters) ;
553535}
554536
555537#[ cfg( test) ]
@@ -621,10 +603,16 @@ mod tests {
621603 language : None ,
622604 features : & [ ] ,
623605 variations : & [ ] ,
624- char_style_indices : & char_style_indices,
625606 } ,
626607 } ] ;
627- shaper. shape_text ( text, & analysis, items, SingleFont ( font) , & mut shaped) ;
608+ shaper. shape_text (
609+ text,
610+ & analysis,
611+ & char_style_indices,
612+ items,
613+ SingleFont ( font) ,
614+ & mut shaped,
615+ ) ;
628616 shaped
629617 }
630618
@@ -732,7 +720,6 @@ mod tests {
732720 language : None ,
733721 features : & [ ] ,
734722 variations : & [ ] ,
735- char_style_indices : & char_style_indices,
736723 } ,
737724 } ,
738725 Item {
@@ -742,11 +729,17 @@ mod tests {
742729 language : None ,
743730 features : & [ ] ,
744731 variations : & [ ] ,
745- char_style_indices : & char_style_indices,
746732 } ,
747733 } ,
748734 ] ;
749- shaper. shape_text ( text, & analysis, items, SingleFont ( font) , & mut shaped) ;
735+ shaper. shape_text (
736+ text,
737+ & analysis,
738+ & char_style_indices,
739+ items,
740+ SingleFont ( font) ,
741+ & mut shaped,
742+ ) ;
750743
751744 let grapheme_starts: Vec < bool > =
752745 shaped. characters . iter ( ) . map ( |c| c. grapheme_start ) . collect ( ) ;
0 commit comments