🔧 Fix text parsing and transformation

This commit is contained in:
Elena Torro 2025-05-27 14:04:27 +02:00
parent 443cabe94e
commit 88e77e3218
2 changed files with 26 additions and 7 deletions

View file

@ -416,9 +416,17 @@ impl RenderState {
} }
Type::Text(text_content) => { Type::Text(text_content) => {
self.surfaces.apply_mut(&[SurfaceId::Fills], |s| { self.surfaces.apply_mut(
s.canvas().concat(&matrix); &[
}); SurfaceId::Fills,
SurfaceId::Strokes,
SurfaceId::DropShadows,
SurfaceId::InnerShadows,
],
|s| {
s.canvas().concat(&matrix);
},
);
let text_content = text_content.new_bounds(shape.selrect()); let text_content = text_content.new_bounds(shape.selrect());
let paragraphs = text_content.get_skia_paragraphs(self.fonts.font_collection()); let paragraphs = text_content.get_skia_paragraphs(self.fonts.font_collection());

View file

@ -197,8 +197,8 @@ impl Default for TextContent {
pub struct Paragraph { pub struct Paragraph {
num_leaves: u32, num_leaves: u32,
text_align: u8, text_align: u8,
text_decoration: u8,
text_direction: u8, text_direction: u8,
text_decoration: u8,
text_transform: u8, text_transform: u8,
line_height: f32, line_height: f32,
letter_spacing: f32, letter_spacing: f32,
@ -212,8 +212,8 @@ impl Default for Paragraph {
Self { Self {
num_leaves: 0, num_leaves: 0,
text_align: 0, text_align: 0,
text_decoration: 0,
text_direction: 0, text_direction: 0,
text_decoration: 0,
text_transform: 0, text_transform: 0,
line_height: 1.0, line_height: 1.0,
letter_spacing: 0.0, letter_spacing: 0.0,
@ -229,8 +229,8 @@ impl Paragraph {
pub fn new( pub fn new(
num_leaves: u32, num_leaves: u32,
text_align: u8, text_align: u8,
text_decoration: u8,
text_direction: u8, text_direction: u8,
text_decoration: u8,
text_transform: u8, text_transform: u8,
line_height: f32, line_height: f32,
letter_spacing: f32, letter_spacing: f32,
@ -241,8 +241,8 @@ impl Paragraph {
Self { Self {
num_leaves, num_leaves,
text_align, text_align,
text_decoration,
text_direction, text_direction,
text_decoration,
text_transform, text_transform,
line_height, line_height,
letter_spacing, letter_spacing,
@ -345,6 +345,8 @@ impl TextLeaf {
3 => skia::textlayout::TextDecoration::OVERLINE, 3 => skia::textlayout::TextDecoration::OVERLINE,
_ => skia::textlayout::TextDecoration::NO_DECORATION, _ => skia::textlayout::TextDecoration::NO_DECORATION,
}); });
// FIXME
style.set_decoration_color(paint.color());
style.set_font_families(&[ style.set_font_families(&[
self.serialized_font_family(), self.serialized_font_family(),
@ -362,6 +364,15 @@ impl TextLeaf {
) -> skia::textlayout::TextStyle { ) -> skia::textlayout::TextStyle {
let mut style = self.to_style(paragraph, &Rect::default()); let mut style = self.to_style(paragraph, &Rect::default());
style.set_foreground_paint(stroke_paint); style.set_foreground_paint(stroke_paint);
style.set_font_size(self.font_size);
style.set_letter_spacing(paragraph.letter_spacing);
style.set_decoration_type(match paragraph.text_decoration {
0 => skia::textlayout::TextDecoration::NO_DECORATION,
1 => skia::textlayout::TextDecoration::UNDERLINE,
2 => skia::textlayout::TextDecoration::LINE_THROUGH,
3 => skia::textlayout::TextDecoration::OVERLINE,
_ => skia::textlayout::TextDecoration::NO_DECORATION,
});
style style
} }