mirror of
https://github.com/penpot/penpot.git
synced 2025-12-12 06:24:17 +01:00
🐛 Fix width on rotation
This commit is contained in:
@@ -205,10 +205,9 @@ fn draw_text(
|
||||
paragraph_builder_groups: &mut [Vec<ParagraphBuilder>],
|
||||
) {
|
||||
let text_content = shape.get_text_content();
|
||||
// FIXME: this does not always return the height we need
|
||||
// let text_height = text_content.size.height;
|
||||
let text_width = text_content.get_width();
|
||||
let text_height = text_content.get_height(text_width);
|
||||
let selrect_width = shape.selrect().width();
|
||||
let text_width = text_content.get_width(selrect_width);
|
||||
let text_height = text_content.get_height(selrect_width);
|
||||
let selrect_height = shape.selrect().height();
|
||||
let mut global_offset_y = match shape.vertical_align() {
|
||||
VerticalAlign::Center => (selrect_height - text_height) / 2.0,
|
||||
|
||||
@@ -330,7 +330,7 @@ impl Shape {
|
||||
self.selrect.set_ltrb(left, top, right, bottom);
|
||||
if let Type::Text(ref mut text) = self.shape_type {
|
||||
text.update_layout(self.selrect);
|
||||
text.set_xywh(left, top, right - left, bottom - top);
|
||||
text.set_xywh(left, top, self.selrect.width(), self.selrect.height());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -403,13 +403,14 @@ impl TextContent {
|
||||
let mut paragraph_builders = self.paragraph_builder_group_from_text(None);
|
||||
let paragraphs =
|
||||
self.build_paragraphs_from_paragraph_builders(&mut paragraph_builders, f32::MAX);
|
||||
|
||||
let (width, height) =
|
||||
paragraphs
|
||||
.iter()
|
||||
.flatten()
|
||||
.fold((0.0, 0.0), |(auto_width, auto_height), paragraph| {
|
||||
(
|
||||
f32::max(paragraph.max_intrinsic_width(), auto_width),
|
||||
f32::max(paragraph.longest_line(), auto_width),
|
||||
auto_height + paragraph.height(),
|
||||
)
|
||||
});
|
||||
@@ -452,11 +453,11 @@ impl TextContent {
|
||||
TextContentLayoutResult(paragraph_builders, paragraphs, size)
|
||||
}
|
||||
|
||||
pub fn get_width(&self) -> f32 {
|
||||
pub fn get_width(&self, width: f32) -> f32 {
|
||||
if self.grow_type() == GrowType::AutoWidth {
|
||||
self.size.width
|
||||
} else {
|
||||
self.bounds.width()
|
||||
width
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user