🐛 Fix text fill gradients and add visual regression test for text styles

This commit is contained in:
Elena Torro 2025-06-18 18:02:28 +02:00
parent bbb9713f97
commit 5c120b601c
4 changed files with 3112 additions and 8 deletions

File diff suppressed because it is too large Load diff

View file

@ -84,3 +84,16 @@ test("Renders a file with texts that use custom fonts", async ({ page }) => {
await expect(workspace.canvas).toHaveScreenshot();
});
test("Renders a file with styled texts", async ({ page }) => {
const workspace = new WasmWorkspacePage(page);
await workspace.setupEmptyFile();
await workspace.mockGetFile("render-wasm/get-file-text-styles.json");
await workspace.goToWorkspace({
id: "6bd7c17d-4f59-815e-8006-5c2559af4939",
pageId: "6bd7c17d-4f59-815e-8006-5c2559af493a",
});
await workspace.waitForFirstRender();
await expect(workspace.canvas).toHaveScreenshot();
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 KiB

View file

@ -344,14 +344,7 @@ impl TextLeaf {
) -> skia::textlayout::TextStyle {
let mut style = skia::textlayout::TextStyle::default();
let bounding_box = Rect::from_xywh(
content_bounds.x(),
content_bounds.y(),
self.font_size * self.text.len() as f32,
self.font_size,
);
let paint = merge_fills(&self.fills, bounding_box);
let paint = merge_fills(&self.fills, *content_bounds);
style.set_foreground_paint(&paint);
style.set_font_size(self.font_size);
style.set_letter_spacing(paragraph.letter_spacing);