CanvasContext.setFontSize

解释:设置字体的字号。

方法参数

Number fontSize:字体的字号

示例

在开发者工具中预览效果

扫码体验

CanvasContext.setFontSize - 图1请使用百度APP扫码

图片示例

CanvasContext.setFontSize - 图2

CanvasContext.setFontSize - 图3

CanvasContext.setFontSize - 图4

代码示例

  1. const canvasContext = swan.createCanvasContext('myCanvas');
  2. canvasContext.setFontSize(20);
  3. canvasContext.fillText('20', 20, 20);
  4. canvasContext.setFontSize(30);
  5. canvasContext.fillText('30', 40, 40);
  6. canvasContext.setFontSize(40);
  7. canvasContext.fillText('40', 60, 60);
  8. canvasContext.setFontSize(50);
  9. canvasContext.fillText('50', 90, 90);
  10. canvasContext.draw();