mirror of
https://github.com/penpot/penpot.git
synced 2025-06-09 13:11:40 +02:00
🎉 Render plain text
* 🎉 Serialize text content (wasm) * ♻️ Refactor functions in main to wasm module * 🎉 Stub rendering of paragraph text (wasm) * 📎 Clean up commented code
This commit is contained in:
parent
9e5de82967
commit
aa468e2153
9 changed files with 256 additions and 9 deletions
12
render-wasm/src/render/text.rs
Normal file
12
render-wasm/src/render/text.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use super::{RenderState, SurfaceId};
|
||||
use crate::shapes::TextContent;
|
||||
|
||||
pub fn render(render_state: &mut RenderState, text: &TextContent) {
|
||||
let mut offset_y = 0.0;
|
||||
for mut skia_paragraph in text.to_paragraphs(&render_state.font_collection) {
|
||||
skia_paragraph.layout(text.width());
|
||||
let xy = (text.x(), text.y() + offset_y);
|
||||
skia_paragraph.paint(render_state.surfaces.canvas(SurfaceId::Fills), xy);
|
||||
offset_y += skia_paragraph.height();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue