Render text properly while dragging and resizing the text Shape

This commit is contained in:
Elena Torro 2025-03-27 12:46:04 +01:00
parent ebf3730454
commit 33c3611345
4 changed files with 16 additions and 7 deletions

View file

@ -1,13 +1,11 @@
use super::{RenderState, SurfaceId};
use super::{RenderState, Shape, SurfaceId};
use crate::shapes::TextContent;
pub fn render(render_state: &mut RenderState, text: &TextContent) {
let mut offset_y = 0.0;
pub fn render(render_state: &mut RenderState, shape: &Shape, text: &TextContent) {
for mut skia_paragraph in text.to_paragraphs(&render_state.fonts().font_collection()) {
skia_paragraph.layout(text.width());
skia_paragraph.layout(shape.width());
let xy = (text.x(), text.y() + offset_y);
let xy = (shape.selrect().x(), shape.selrect.y());
skia_paragraph.paint(render_state.surfaces.canvas(SurfaceId::Fills), xy);
offset_y += skia_paragraph.height();
}
}