@@ -60,14 +60,21 @@ impl TextRenderer {
6060 let resolution = viewport. resolution ( ) ;
6161
6262 for text_area in text_areas {
63+ let bounds_min_x = text_area. bounds . left . max ( 0 ) ;
64+ let bounds_min_y = text_area. bounds . top . max ( 0 ) ;
65+ let bounds_max_x = text_area. bounds . right . min ( resolution. width as i32 ) ;
66+ let bounds_max_y = text_area. bounds . bottom . min ( resolution. height as i32 ) ;
67+
6368 let is_run_visible = |run : & cosmic_text:: LayoutRun | {
6469 let start_y = ( text_area. top + run. line_top ) as i32 ;
6570 let end_y = ( text_area. top + run. line_top + run. line_height ) as i32 ;
6671
67- start_y <= text_area . bounds . bottom && text_area . bounds . top <= end_y
72+ start_y <= bounds_max_y && bounds_min_y <= end_y
6873 } ;
6974
70- let layout_runs = text_area. buffer . layout_runs ( )
75+ let layout_runs = text_area
76+ . buffer
77+ . layout_runs ( )
7178 . skip_while ( |run| !is_run_visible ( run) )
7279 . take_while ( is_run_visible) ;
7380
@@ -198,11 +205,6 @@ impl TextRenderer {
198205 let mut width = details. width as i32 ;
199206 let mut height = details. height as i32 ;
200207
201- let bounds_min_x = text_area. bounds . left . max ( 0 ) ;
202- let bounds_min_y = text_area. bounds . top . max ( 0 ) ;
203- let bounds_max_x = text_area. bounds . right . min ( resolution. width as i32 ) ;
204- let bounds_max_y = text_area. bounds . bottom . min ( resolution. height as i32 ) ;
205-
206208 // Starts beyond right edge or ends beyond left edge
207209 let max_x = x + width;
208210 if x > bounds_max_x || max_x < bounds_min_x {
0 commit comments