@@ -12,7 +12,8 @@ use crate::conv::{to_u32, to_usize};
1212use crate :: fonts:: { self , FontSelector , NoFontMatch } ;
1313use crate :: format:: FormattableText ;
1414use crate :: util:: ends_with_hard_break;
15- use crate :: { Direction , Range , script_to_fontique, shaper} ;
15+ use crate :: { Direction , Range , shaper} ;
16+ use icu_properties:: { CodePointMapData , props:: Script } ;
1617use icu_segmenter:: LineSegmenter ;
1718use unicode_bidi:: { BidiInfo , LTR_LEVEL , RTL_LEVEL } ;
1819
@@ -195,7 +196,7 @@ impl TextDisplay {
195196 text,
196197 dpem,
197198 level : levels. first ( ) . cloned ( ) . unwrap_or ( LTR_LEVEL ) ,
198- script : UNKNOWN_SCRIPT ,
199+ script : Script :: Unknown . into ( ) ,
199200 } ;
200201
201202 let mut start = 0 ;
@@ -206,7 +207,6 @@ impl TextDisplay {
206207 let mut break_iter = segmenter. segment_str ( text) ;
207208 let mut next_break = break_iter. next ( ) ;
208209
209- let mut analyzer = swash:: text:: analyze ( text. chars ( ) ) ;
210210 let mut first_real = None ;
211211
212212 let mut last_is_control = false ;
@@ -222,7 +222,7 @@ impl TextDisplay {
222222 let is_htab = c == '\t' ;
223223 let control_break = is_htab || ( last_is_control && !is_control) ;
224224
225- let ( props , _ ) = analyzer . next ( ) . unwrap ( ) ;
225+ let script = CodePointMapData :: < Script > :: new ( ) . get ( c ) ;
226226
227227 // Is wrapping allowed at this position?
228228 let is_break = next_break == Some ( index) ;
@@ -244,14 +244,12 @@ impl TextDisplay {
244244 }
245245
246246 let mut new_script = None ;
247- if props . script ( ) . is_real ( ) {
247+ if ! matches ! ( script , Script :: Common | Script :: Unknown | Script :: Inherited ) {
248248 if first_real. is_none ( ) && !c. is_control ( ) {
249249 first_real = Some ( c) ;
250250 }
251- let script = script_to_fontique ( props. script ( ) ) ;
252- if input. script == UNKNOWN_SCRIPT {
253- input. script = script;
254- } else if script != UNKNOWN_SCRIPT && script != input. script {
251+ let script = script. into ( ) ;
252+ if script != input. script {
255253 new_script = Some ( script) ;
256254 }
257255 }
@@ -271,7 +269,7 @@ impl TextDisplay {
271269 start = index;
272270 non_control_end = index;
273271 input. level = levels[ index] ;
274- input. script = UNKNOWN_SCRIPT ;
272+ input. script = Script :: Unknown . into ( ) ;
275273 breaks = Default :: default ( ) ;
276274 } else if is_break && !is_control {
277275 // We do break runs when hitting control chars, but only when
@@ -287,7 +285,6 @@ impl TextDisplay {
287285 }
288286 }
289287
290- debug_assert ! ( analyzer. next( ) . is_none( ) ) ;
291288 let is_break = next_break == Some ( text. len ( ) ) ;
292289 let hard_break = is_break && ends_with_hard_break ( & text) ;
293290
@@ -345,16 +342,3 @@ impl TextDisplay {
345342 Ok ( ( ) )
346343 }
347344}
348-
349- trait ScriptExt {
350- #[ allow( clippy:: wrong_self_convention) ]
351- fn is_real ( self ) -> bool ;
352- }
353- impl ScriptExt for swash:: text:: Script {
354- fn is_real ( self ) -> bool {
355- use swash:: text:: Script :: * ;
356- !matches ! ( self , Common | Unknown | Inherited )
357- }
358- }
359-
360- pub ( crate ) const UNKNOWN_SCRIPT : fontique:: Script = fontique:: Script ( * b"Zzzz" ) ;
0 commit comments