I can't get the Font size on my canvas to work

Viewed 6

I'm using npm CANVAS, but the font property doesn't work

    const { createCanvas, loadImage } = require('canvas');
   
    const canvas = createCanvas(200, 200)
    const ctx = canvas.getContext('2d')

    ctx.font = '30px'
    ctx.fillText('Awesome!', 50, 100)
    ctx.font = '50px'
    ctx.fillText('Awesome!', 50, 140)

    console.log('<img src="' + canvas.toDataURL() + '" />')

It doesn't change the font size according to my code, it remains as the first callctx.font = '30px'

Im using "canvas": "^2.10.1"

0 Answers
Related