Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
HTML5 Canvas Font Size Based on Canvas Size
To scale fonts, let us see an example.
Canvas: 800px Font Size: 60px
You need to use the following code for our example to scale font size based on canvas −
var fontBase = 800;
var fontSize = 60;
function getFont() {
var ratio = fontSize / fontBase;
var cSize = canvas.width * ratio;
return (cSize |0) + 'px sans-serif';
} Advertisements
