Negative letterspcing does not work
Closed this issue · 2 comments
loveloki commented
Negative letterspcing does not work
This is code:
import { Canvas } from "skia-canvas";
let canvas = new Canvas(400, 400);
let ctx = canvas.getContext("2d");
ctx.fillStyle = "purple";
const text = "letterSpacing test";
ctx.font = "normal 20pt sans";
ctx.letterSpacing = "-100px";
ctx.fillText(text, 10, 50);
ctx.letterSpacing = "0px";
ctx.fillText(text, 10, 75);
ctx.letterSpacing = "100px";
ctx.fillText(text, 10, 100);
await canvas.saveAs("output.pdf");
I tried looking at the repo code, but it seems like there is nothing wrong...
I'm poor Rust knowledge, How should I debug this issue?
samizdatco commented
The regex that was being used to parse & validate css 'size' strings was rejecting anything beginning with a -
. I've now made a special case for the letterSpacing
and wordSpacing
values where they're allowed to define negative sizes. Thanks for finding this bug; it had totally slipped through the cracks when I was testing!
loveloki commented
@samizdatco Thanks your explanation!