Merge pull request #6573 from penpot/elenatorro-11021-text-fixes

🔧 Fix text parsing and transformation
This commit is contained in:
Elena Torró 2025-05-29 09:33:05 +02:00 committed by GitHub
commit fe60016124
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 52 additions and 17 deletions

View file

@ -19,7 +19,7 @@ use options::RenderOptions;
use surfaces::{SurfaceId, Surfaces};
use crate::performance;
use crate::shapes::{modified_children_ids, Corners, Shape, StructureEntry, Type};
use crate::shapes::{modified_children_ids, Corners, Shape, StrokeKind, StructureEntry, Type};
use crate::tiles::{self, TileRect, TileViewbox, TileWithDistance};
use crate::uuid::Uuid;
use crate::view::Viewbox;
@ -423,9 +423,17 @@ impl RenderState {
}
Type::Text(text_content) => {
self.surfaces.apply_mut(&[SurfaceId::Fills], |s| {
s.canvas().concat(&matrix);
});
self.surfaces.apply_mut(
&[
SurfaceId::Fills,
SurfaceId::Strokes,
SurfaceId::DropShadows,
SurfaceId::InnerShadows,
],
|s| {
s.canvas().concat(&matrix);
},
);
let text_content = text_content.new_bounds(shape.selrect());
let paragraphs = text_content.get_skia_paragraphs(self.fonts.font_collection());
@ -440,13 +448,21 @@ impl RenderState {
self.fonts.font_collection(),
);
shadows::render_text_drop_shadows(self, &shape, &stroke_paragraphs, antialias);
text::render(
self,
&shape,
&stroke_paragraphs,
Some(SurfaceId::Strokes),
None,
);
if stroke.kind == StrokeKind::Inner {
// Inner strokes must be rendered on the Fills surface because their blend modes
// (e.g., SrcATop, DstOver) rely on the text fill already being present underneath.
// Rendering them on a separate surface would break this blending and result in incorrect visuals as
// black color background.
text::render(self, &shape, &stroke_paragraphs, None, None);
} else {
text::render(
self,
&shape,
&stroke_paragraphs,
Some(SurfaceId::Strokes),
None,
);
}
shadows::render_text_inner_shadows(self, &shape, &stroke_paragraphs, antialias);
}