Skip to content

Commit 3e371e5

Browse files
committed
text: Use layout_to_local_matrix when calculating line metrics
This makes sure that the device-text specific transforms are applied.
1 parent 2b69ba3 commit 3e371e5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

core/src/display_object/edit_text.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2272,13 +2272,15 @@ impl<'gc> EditText<'gc> {
22722272
let line = layout.lines().get(line)?;
22732273
let bounds = line.bounds();
22742274

2275+
// TODO What about internal bounds?
2276+
let bounds = self.layout_to_local_matrix() * bounds;
22752277
Some(LayoutMetrics {
22762278
ascent: line.ascent(),
22772279
descent: line.descent(),
22782280
leading: line.leading(),
22792281
width: bounds.width(),
22802282
height: bounds.height() + line.leading(),
2281-
x: bounds.offset_x() + Self::GUTTER,
2283+
x: bounds.offset_x(),
22822284
})
22832285
}
22842286

core/src/html/dimensions.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,16 @@ where
231231
}
232232
}
233233

234+
impl std::ops::Mul<BoxBounds<Twips>> for ruffle_render::matrix::Matrix {
235+
type Output = BoxBounds<Twips>;
236+
237+
fn mul(self, bounds: BoxBounds<Twips>) -> BoxBounds<Twips> {
238+
// BoxBounds have the same semantics as Rectangle when applying a matrix
239+
let bounds: Rectangle<Twips> = bounds.into();
240+
(self * bounds).into()
241+
}
242+
}
243+
234244
impl<T> BoxBounds<T>
235245
where
236246
T: Add<T, Output = T> + Sub<T, Output = T> + Copy,

0 commit comments

Comments
 (0)