mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
🐛 Fix paragraph layout width on autowidth
This commit is contained in:
@@ -14,10 +14,17 @@ pub fn render(
|
||||
let canvas = render_state
|
||||
.surfaces
|
||||
.canvas(surface_id.unwrap_or(SurfaceId::Fills));
|
||||
let container_height = shape.selrect().height();
|
||||
|
||||
// Calculate total height for vertical alignment
|
||||
let total_content_height = calculate_all_paragraphs_height(paragraphs, shape.bounds().width());
|
||||
// Width
|
||||
let paragraph_width = if let crate::shapes::Type::Text(text_content) = &shape.shape_type {
|
||||
text_content.get_width()
|
||||
} else {
|
||||
shape.width()
|
||||
};
|
||||
|
||||
// Height
|
||||
let container_height = shape.selrect().height();
|
||||
let total_content_height = calculate_all_paragraphs_height(paragraphs, paragraph_width);
|
||||
let mut global_offset_y = match shape.vertical_align() {
|
||||
VerticalAlign::Center => (container_height - total_content_height) / 2.0,
|
||||
VerticalAlign::Bottom => container_height - total_content_height,
|
||||
@@ -48,8 +55,7 @@ pub fn render(
|
||||
continue;
|
||||
}
|
||||
|
||||
skia_paragraph.layout(shape.bounds().width());
|
||||
|
||||
skia_paragraph.layout(paragraph_width);
|
||||
let paragraph_height = skia_paragraph.height();
|
||||
let xy = (shape.selrect().x(), shape.selrect().y() + group_offset_y);
|
||||
skia_paragraph.paint(canvas, xy);
|
||||
@@ -126,7 +132,7 @@ pub fn render(
|
||||
// For stroke groups (multiple elements), increment global_offset_y once per group
|
||||
if group_len > 1 {
|
||||
let mut first_paragraph = group[0].build();
|
||||
first_paragraph.layout(shape.bounds().width());
|
||||
first_paragraph.layout(paragraph_width);
|
||||
global_offset_y += first_paragraph.height();
|
||||
} else {
|
||||
// For regular paragraphs, global_offset_y was already incremented inside the loop
|
||||
|
||||
Reference in New Issue
Block a user