mirror of
https://github.com/penpot/penpot.git
synced 2025-06-07 17:41:40 +02:00
✨ Render text properly while dragging and resizing the text Shape
This commit is contained in:
parent
ebf3730454
commit
33c3611345
4 changed files with 16 additions and 7 deletions
|
@ -380,7 +380,10 @@ impl RenderState {
|
|||
}
|
||||
}
|
||||
Type::Text(text_content) => {
|
||||
text::render(self, text_content);
|
||||
self.surfaces.apply_mut(&[SurfaceId::Fills], |s| {
|
||||
s.canvas().concat(&matrix);
|
||||
});
|
||||
text::render(self, &shape, text_content);
|
||||
}
|
||||
_ => {
|
||||
self.surfaces.apply_mut(
|
||||
|
@ -594,6 +597,7 @@ impl RenderState {
|
|||
}
|
||||
let scale = self.get_scale();
|
||||
let mut should_stop = false;
|
||||
|
||||
while !should_stop {
|
||||
if let Some(current_tile) = self.current_tile {
|
||||
if self.surfaces.has_cached_tile_surface(current_tile) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -575,6 +575,10 @@ impl Shape {
|
|||
self.hidden
|
||||
}
|
||||
|
||||
pub fn width(&self) -> f32 {
|
||||
self.selrect.width()
|
||||
}
|
||||
|
||||
pub fn visually_insignificant(&self, scale: f32) -> bool {
|
||||
self.selrect.width() * scale < MIN_VISIBLE_SIZE
|
||||
|| self.selrect.height() * scale < MIN_VISIBLE_SIZE
|
||||
|
|
|
@ -26,14 +26,17 @@ impl TextContent {
|
|||
self.bounds = Rect::from_xywh(x, y, w, h);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn width(&self) -> f32 {
|
||||
self.bounds.width()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn x(&self) -> f32 {
|
||||
self.bounds.x()
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn y(&self) -> f32 {
|
||||
self.bounds.y()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue