mirror of
https://github.com/penpot/penpot.git
synced 2025-07-19 16:27:30 +02:00
🐛 Fix some problems with layouts
This commit is contained in:
parent
6cd2c712ab
commit
5d42b9793b
6 changed files with 30 additions and 7 deletions
|
@ -1,5 +1,5 @@
|
|||
use crate::mem;
|
||||
use crate::shapes::{auto_height, auto_width, GrowType, RawTextData, Type};
|
||||
use crate::shapes::{auto_height, auto_width, max_width, GrowType, RawTextData, Type};
|
||||
|
||||
use crate::STATE;
|
||||
use crate::{with_current_shape, with_state};
|
||||
|
@ -42,6 +42,7 @@ pub extern "C" fn get_text_dimensions() -> *mut u8 {
|
|||
|
||||
let mut width = 0.01;
|
||||
let mut height = 0.01;
|
||||
let mut m_width = 0.01;
|
||||
with_current_shape!(state, |shape: &mut Shape| {
|
||||
width = shape.selrect.width();
|
||||
height = shape.selrect.height();
|
||||
|
@ -49,14 +50,16 @@ pub extern "C" fn get_text_dimensions() -> *mut u8 {
|
|||
if let Type::Text(content) = &shape.shape_type {
|
||||
let paragraphs = content.get_skia_paragraphs(font_col);
|
||||
height = auto_height(¶graphs).ceil();
|
||||
m_width = max_width(¶graphs);
|
||||
if content.grow_type() == GrowType::AutoWidth {
|
||||
width = auto_width(¶graphs).ceil();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let mut bytes = vec![0; 8];
|
||||
let mut bytes = vec![0; 12];
|
||||
bytes[0..4].clone_from_slice(&width.to_le_bytes());
|
||||
bytes[4..8].clone_from_slice(&height.to_le_bytes());
|
||||
bytes[8..12].clone_from_slice(&m_width.to_le_bytes());
|
||||
mem::write_bytes(bytes)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue