canvasContext.setFontSize

解释:设置字体的字号。

参数:

参数名类型说明
fontSizeNumber字体的字号

示例:

  1. const ctx = swan.createCanvasContext('myCanvas');

    ctx.setFontSize(20);
    ctx.fillText('20', 20, 20);
    ctx.setFontSize(30);
    ctx.fillText('30', 40, 40);
    ctx.setFontSize(40);
    ctx.fillText('40', 60, 60);
    ctx.setFontSize(50);
    ctx.fillText('50', 90, 90);

    ctx.draw();

图片