CanvasContext.setFontSize

解释:设置字体的字号。

# 方法参数

Number fontSize:字体的字号

# 示例

扫码体验
重新加载
请使用百度APP扫码

# 图片示例

# 代码示例

    <canvas canvas-id="myCanvas" class="myCanvas" />
    
    Page({
        onLoad() {
            const canvasContext = swan.createCanvasContext('myCanvas');
            canvasContext.setFontSize(20);
            canvasContext.fillText('20', 20, 20);
            canvasContext.setFontSize(30);
            canvasContext.fillText('30', 40, 40);
            canvasContext.setFontSize(40);
            canvasContext.fillText('40', 60, 60);
            canvasContext.setFontSize(50);
            canvasContext.fillText('50', 90, 90);
            canvasContext.draw();
        }
    });