Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 Canvas Font Size Based on Canvas Size

Tags:

People also ask

What font size does canvas use?

The default font is 10px sans-serif.

Is HTML5 canvas still used?

The HTML5 canvas has the potential to become a staple of the web, enjoying ubiquitous browser and platform support in addition to widespread webpage support, as nearly 90% of websites have ported to HTML5.

How do you scale a canvas in HTML?

You can scale your canvas with content by "bouncing" the content off a temporary canvas while you resize the original canvas. This save+redraw process is necessary because canvas content is automatically cleared when you resize the canvas width or height. So .


I have the canvas size set to 1/3 the window.innerHeight and window.innerWidth of the browser.

Most of the elements on the canvas are also set based on the width and height of the canvas, so that they scale down in size and are positioned based on the size of the canvas.

How do I scale font sizes based on this as well?

For example, the font size of my opening screen of a game I'm making, is 80pt. That's way too big if the browser is really small. It goes off the canvas.