Fix the is_run_visible calculation (#134)

* Fix the `is_run_visible` calculation

* Clarify variable names in the `is_run_visible` calculation

* Make the physical run_line scales `i32` instead of `f32`

* Make entire `start_y_physical` expression in `is_run_visible` calculation an `i32`
This commit is contained in:
StratusFearMe21 2025-03-04 19:36:29 -07:00 committed by Héctor Ramón Jiménez
parent 505f12f6ce
commit 9ab32ae1c3
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -73,10 +73,10 @@ impl TextRenderer {
let bounds_max_y = text_area.bounds.bottom.min(resolution.height as i32); let bounds_max_y = text_area.bounds.bottom.min(resolution.height as i32);
let is_run_visible = |run: &cosmic_text::LayoutRun| { let is_run_visible = |run: &cosmic_text::LayoutRun| {
let start_y = (text_area.top + run.line_top) as i32; let start_y_physical = (text_area.top + (run.line_top * text_area.scale)) as i32;
let end_y = (text_area.top + run.line_top + run.line_height) as i32; let end_y_physical = start_y_physical + (run.line_height * text_area.scale) as i32;
start_y <= text_area.bounds.bottom && text_area.bounds.top <= end_y start_y_physical <= text_area.bounds.bottom && text_area.bounds.top <= end_y_physical
}; };
let layout_runs = text_area let layout_runs = text_area