Skip to content

Commit 2b69ba3

Browse files
committed
text: Transform text size using layout_to_local_matrix
This is needed as this transformation applies device-text specific scaling.
1 parent 61a882f commit 2b69ba3

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

core/src/display_object/edit_text.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,7 @@ impl<'gc> EditText<'gc> {
976976
/// The returned tuple should be interpreted as width, then height.
977977
pub fn measure_text(self, _context: &mut UpdateContext<'gc>) -> (Twips, Twips) {
978978
let text_size = self.0.layout.borrow().text_size();
979+
let text_size = self.layout_to_local_matrix() * text_size;
979980
(text_size.width(), text_size.height())
980981
}
981982

core/src/html/dimensions.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,34 @@ impl<T> From<Position<T>> for Size<T> {
152152
}
153153
}
154154

155+
impl From<swf::PointDelta<Twips>> for Size<Twips> {
156+
fn from(size: swf::PointDelta<Twips>) -> Self {
157+
Self {
158+
width: size.dx,
159+
height: size.dy,
160+
}
161+
}
162+
}
163+
164+
impl From<Size<Twips>> for swf::PointDelta<Twips> {
165+
fn from(size: Size<Twips>) -> Self {
166+
Self {
167+
dx: size.width,
168+
dy: size.height,
169+
}
170+
}
171+
}
172+
173+
impl std::ops::Mul<Size<Twips>> for ruffle_render::matrix::Matrix {
174+
type Output = Size<Twips>;
175+
176+
fn mul(self, size: Size<Twips>) -> Size<Twips> {
177+
// Size has the same semantics as PointDelta when applying a matrix
178+
let size: swf::PointDelta<Twips> = size.into();
179+
(self * size).into()
180+
}
181+
}
182+
155183
/// A type which represents the offset and size of a text box.
156184
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
157185
pub struct BoxBounds<T> {

0 commit comments

Comments
 (0)