Add scale content to render wasm

This commit is contained in:
alonso.torres
2025-05-28 14:40:39 +02:00
parent 46b0e4f0e7
commit bcfa9a82ea
18 changed files with 282 additions and 33 deletions

View File

@@ -34,9 +34,9 @@ impl GrowType {
#[derive(Debug, PartialEq, Clone)]
pub struct TextContent {
paragraphs: Vec<Paragraph>,
bounds: Rect,
grow_type: GrowType,
pub paragraphs: Vec<Paragraph>,
pub bounds: Rect,
pub grow_type: GrowType,
}
pub fn set_paragraphs_width(width: f32, paragraphs: &mut Vec<Vec<skia::textlayout::Paragraph>>) {
@@ -284,6 +284,13 @@ impl Paragraph {
});
style
}
pub fn scale_content(&mut self, value: f32) {
self.letter_spacing *= value;
self.children
.iter_mut()
.for_each(|l| l.scale_content(value));
}
}
#[derive(Debug, PartialEq, Clone)]
@@ -388,6 +395,10 @@ impl TextLeaf {
_ => self.text.clone(),
}
}
pub fn scale_content(&mut self, value: f32) {
self.font_size *= value;
}
}
const RAW_PARAGRAPH_DATA_SIZE: usize = std::mem::size_of::<RawParagraphData>();