提交 2092d21a 编写于 作者: L liyongning 提交者: 折腾笔记

fix: 解决 H5 端 canvas 无法绘制文字的 bug

上级 f9a53ffe
......@@ -129,7 +129,12 @@ export function initHidpi() {
args[1] *= pixelRatio
args[2] *= pixelRatio
args[3] *= pixelRatio
// 因为 canvasCtx.fillText 的第 4 个参数为可选参数,用户可能不传,
// 所以在处理时需要判断一下,否则 undefined * pixelRatio => NaN,
// 会导致 canvas 无法绘制。
if (args[3] && typeof args[3] === 'number') {
args[3] *= pixelRatio
}
var font = this.font
this.font = font.replace(
......@@ -154,7 +159,12 @@ export function initHidpi() {
args[1] *= pixelRatio // x
args[2] *= pixelRatio // y
args[3] *= pixelRatio
// 因为 canvasCtx.strokeText 的第 4 个参数为可选参数,用户可能不传,
// 所以在处理时需要判断一下,否则 undefined * pixelRatio => NaN,
// 会导致 canvas 无法绘制。
if (args[3] && typeof args[3] === 'number') {
args[3] *= pixelRatio
}
var font = this.font
this.font = font.replace(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册