mirror of
https://github.com/penpot/penpot.git
synced 2025-07-19 07:07:13 +02:00
Merge pull request #6491 from penpot/alotor-perf-pixel-precision
✨ Pixel precision for new renderer
This commit is contained in:
commit
58b1cf6b0c
8 changed files with 76 additions and 22 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