-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Text antialiasing can’t be disabled #25
Comments
@gc hey, I'm the original author of the rust-skia project, maybe you can try this https://github.com/Brooooooklyn/canvas project, which aim to provide zero system dependencies and high performance of canvas implementation for Node.js. @samizdatco I just noticed your heavy work on this project! This is amazing. I start skr-canvas from scrach instead of /cc @pragmatrix |
As far as I know, the canvas standard doesn't provide a way to disable antialiasing/smoothing beyond the specific case of resizing bitmap images (whether in a All of which is to say, it's the node-canvas behavior that's actually unexpected here. But it also seems like a genuinely useful thing to be able to control, especially for pixel-art use cases like yours. It might make more sense to turn it into a separate |
Yep. It is impossible to The way I see it, it comes down to: is it possible for you to control anti-aliasing, so you can implement a thing like |
So it actually looks like the antialiasing setting may be inaccessible since However, I think you can achieve the hard-edged-characters effect you want by using the newly added For instance: FontLibrary.use('./osrs-font-compact.otf');
ctx.font = '16px OSRSFontCompact';
ctx.fillStyle = 'black';
// blurry
ctx.fillText("It's dangerous to go alone! Take this.", 10, 16)
// sharp edged
let textPath = ctx.outlineText('You are likely to be eaten by a grue.')
ctx.fill(textPath.offset(10, 32)) |
I improved my test case so it tries out one of the other fonts I use, and for some reason this second font ( |
Seems fine to me: FontLibrary.use(['osrs-font-compact.otf','./osrs-font-bold.ttf']);
ctx.font = '16px "RuneScape Bold 12"';
ctx.fillStyle = 'black';
// blurry
ctx.fillText("It's dangerous to go alone! Take this.", 10, 16)
// sharp edged
let textPath = ctx.outlineText('You are likely to be eaten by a grue.')
ctx.fill(textPath.offset(10, 32)) |
I'm looking at migrating from node-canvas, and I've noticed a difference between the text drawing which is a big problem for me because I use several small/pixel-art fonts, I don't know if its a bug or just I'm not using something correctly - please let me know! Thanks
Code / Minimal reproduction (used to generate that image^): https://github.com/gc/skia-canvas-test
The text was updated successfully, but these errors were encountered: