Apply Transform scaling to text primitives
This commit is contained in:
parent
9b8614a4e2
commit
aa41d7656e
3 changed files with 17 additions and 2 deletions
|
|
@ -26,3 +26,11 @@ impl From<Pixels> for f32 {
|
||||||
pixels.0
|
pixels.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::ops::Mul<f32> for Pixels {
|
||||||
|
type Output = Pixels;
|
||||||
|
|
||||||
|
fn mul(self, rhs: f32) -> Self {
|
||||||
|
Pixels(self.0 * rhs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ impl<'a> Layer<'a> {
|
||||||
layer.text.push(Text::Cached(text::Cached {
|
layer.text.push(Text::Cached(text::Cached {
|
||||||
content,
|
content,
|
||||||
bounds: *bounds * transformation,
|
bounds: *bounds * transformation,
|
||||||
size: *size,
|
size: *size * transformation.scale_y(),
|
||||||
line_height: *line_height,
|
line_height: *line_height,
|
||||||
color: *color,
|
color: *color,
|
||||||
font: *font,
|
font: *font,
|
||||||
|
|
|
||||||
|
|
@ -124,11 +124,13 @@ impl Pipeline {
|
||||||
vertical_alignment,
|
vertical_alignment,
|
||||||
color,
|
color,
|
||||||
clip_bounds,
|
clip_bounds,
|
||||||
|
scale,
|
||||||
) = match section {
|
) = match section {
|
||||||
Text::Paragraph {
|
Text::Paragraph {
|
||||||
position,
|
position,
|
||||||
color,
|
color,
|
||||||
clip_bounds,
|
clip_bounds,
|
||||||
|
scale,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
use crate::core::text::Paragraph as _;
|
use crate::core::text::Paragraph as _;
|
||||||
|
|
@ -145,12 +147,14 @@ impl Pipeline {
|
||||||
paragraph.vertical_alignment(),
|
paragraph.vertical_alignment(),
|
||||||
*color,
|
*color,
|
||||||
*clip_bounds,
|
*clip_bounds,
|
||||||
|
*scale,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Text::Editor {
|
Text::Editor {
|
||||||
position,
|
position,
|
||||||
color,
|
color,
|
||||||
clip_bounds,
|
clip_bounds,
|
||||||
|
scale,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
use crate::core::text::Editor as _;
|
use crate::core::text::Editor as _;
|
||||||
|
|
@ -167,6 +171,7 @@ impl Pipeline {
|
||||||
alignment::Vertical::Top,
|
alignment::Vertical::Top,
|
||||||
*color,
|
*color,
|
||||||
*clip_bounds,
|
*clip_bounds,
|
||||||
|
*scale,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Text::Cached(text) => {
|
Text::Cached(text) => {
|
||||||
|
|
@ -186,6 +191,7 @@ impl Pipeline {
|
||||||
text.vertical_alignment,
|
text.vertical_alignment,
|
||||||
text.color,
|
text.color,
|
||||||
text.clip_bounds,
|
text.clip_bounds,
|
||||||
|
1.0,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Text::Raw(text) => {
|
Text::Raw(text) => {
|
||||||
|
|
@ -205,6 +211,7 @@ impl Pipeline {
|
||||||
alignment::Vertical::Top,
|
alignment::Vertical::Top,
|
||||||
text.color,
|
text.color,
|
||||||
text.clip_bounds,
|
text.clip_bounds,
|
||||||
|
1.0,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -234,7 +241,7 @@ impl Pipeline {
|
||||||
buffer,
|
buffer,
|
||||||
left,
|
left,
|
||||||
top,
|
top,
|
||||||
scale: scale_factor,
|
scale: scale * scale_factor,
|
||||||
bounds: glyphon::TextBounds {
|
bounds: glyphon::TextBounds {
|
||||||
left: clip_bounds.x as i32,
|
left: clip_bounds.x as i32,
|
||||||
top: clip_bounds.y as i32,
|
top: clip_bounds.y as i32,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue