js canvas text font

Solutions on MaxInterview for js canvas text font by the best coders in the world

showing results for - "js canvas text font"
26 Jan 2017
2  <head>
3    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100&display=swap" rel="stylesheet">
4  </head>
5  <body>
6    <p>to use external fonts you must have them linked to the dom</p>
7    <canvas id="c" width="500" height="300"></canvas>
8    <script>
9    var c = document.getElementById("c");
10    var ctx = c.getContext("2d");
11    ctx.font = "40px Roboto";//notice that behind the px comes the font family name
12    ctx.fillText("hello world",40,40);
13    </script>
14  </body>
similar questions
queries leading to this page
js canvas text font