@@ -9,7 +9,6 @@ use ruffle_render::shape_utils::{DrawCommand, FillRule};
99use ruffle_render:: transform:: Transform ;
1010use std:: borrow:: Cow ;
1111use std:: cell:: { OnceCell , RefCell } ;
12- use std:: cmp:: max;
1312use std:: hash:: { Hash , Hasher } ;
1413use swf:: FillStyle ;
1514
@@ -618,35 +617,20 @@ impl<'gc> Font<'gc> {
618617 }
619618 }
620619
621- /// Measure a particular string's metrics (width and height).
622- pub fn measure ( & self , text : & WStr , params : EvalParameters ) -> ( Twips , Twips ) {
623- let round = false ;
620+ /// Measure a particular string's width.
621+ pub fn measure ( & self , text : & WStr , params : EvalParameters ) -> Twips {
624622 let mut width = Twips :: ZERO ;
625- let mut height = Twips :: ZERO ;
626623
627624 self . evaluate (
628625 text,
629626 Default :: default ( ) ,
630627 params,
631- |_pos, transform, _glyph, advance, _x| {
632- let tx = transform. matrix . tx ;
633- let ty = transform. matrix . ty ;
634-
635- if round {
636- width = width. max ( ( tx + advance) . trunc_to_pixel ( ) ) ;
637- height = height. max ( ty. trunc_to_pixel ( ) ) ;
638- } else {
639- width = width. max ( tx + advance) ;
640- height = height. max ( ty) ;
641- }
628+ |_pos, _transform, _glyph, advance, x| {
629+ width = width. max ( x + advance) ;
642630 } ,
643631 ) ;
644632
645- if text. is_empty ( ) {
646- height = max ( height, params. height ) ;
647- }
648-
649- ( width, height)
633+ width
650634 }
651635
652636 /// Given a line of text, find the first breakpoint within the text.
@@ -690,17 +674,17 @@ impl<'gc> Font<'gc> {
690674 params,
691675 ) ;
692676
693- if is_start_of_line && measure. 0 > remaining_width {
677+ if is_start_of_line && measure > remaining_width {
694678 //Failsafe for if we get a word wider than the field.
695- let mut last_passing_breakpoint = ( Twips :: ZERO , Twips :: ZERO ) ;
679+ let mut last_passing_breakpoint = Twips :: ZERO ;
696680
697681 let cur_slice = & text[ word_start..] ;
698682 let mut char_iter = cur_slice. char_indices ( ) ;
699683 let mut prev_char_index = word_start;
700684 let mut prev_frag_end = 0 ;
701685
702686 char_iter. next ( ) ; // No need to check cur_slice[0..0]
703- while last_passing_breakpoint. 0 < remaining_width {
687+ while last_passing_breakpoint < remaining_width {
704688 prev_char_index = word_start + prev_frag_end;
705689
706690 if let Some ( ( frag_end, _) ) = char_iter. next ( ) {
@@ -713,7 +697,7 @@ impl<'gc> Font<'gc> {
713697 }
714698
715699 return Some ( prev_char_index) ;
716- } else if measure. 0 > remaining_width {
700+ } else if measure > remaining_width {
717701 //The word is wider than our remaining width, return the end of
718702 //the line.
719703 return Some ( line_end) ;
@@ -724,7 +708,7 @@ impl<'gc> Font<'gc> {
724708
725709 //If the additional space were to cause an overflow, then
726710 //return now.
727- remaining_width -= measure. 0 ;
711+ remaining_width -= measure;
728712 if remaining_width < Twips :: from_pixels ( 0.0 ) {
729713 return Some ( word_end) ;
730714 }
0 commit comments