I'm making a game with a canvas scaled up such that each pixel is pretty big. I want to display some pixelated text without anti-aliasing but I have idea how I would accomplish this.

Is there I way can do such a thing?


  • 2
    \$\begingroup\$ How are you drawing your text so far? \$\endgroup\$ – DMGregory Jun 3 at 14:41
  • \$\begingroup\$ Have you considered to just use a pixely font? \$\endgroup\$ – Philipp Jun 3 at 19:54
  • \$\begingroup\$ I'm using ctx.fillText(), and ctx.font to style it. I would use a custom font but I don't know how to draw custom fonts into the canvas. \$\endgroup\$ – mushrombrother.jpg Jun 4 at 14:55
  • \$\begingroup\$ Update: I've figured out how to import a custom font and draw it to the canvas, but there is still an anti-aliasing effect. \$\endgroup\$ – mushrombrother.jpg Jun 4 at 15:25
  • \$\begingroup\$ I've found the solution! you need to disable font smoothing for all elements in the css. \$\endgroup\$ – mushrombrother.jpg Jun 4 at 15:40

In the css, you need to disable font smoothing for canvas:

    font-smooth: never;
    -webkit-font-smoothing : none;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.