提交 a1b9912f 编写于 作者: Q qiang

fix: 修复部分设备 canvasContext.fillText 多次调用失败的问题

上级 cf40fb71
......@@ -106,8 +106,9 @@ if (pixelRatio !== 1) {
args[1] *= pixelRatio
args[2] *= pixelRatio
this.font = this.font.replace(
/(\d+)(px|em|rem|pt)/g,
var font = this.font
this.font = font.replace(
/(\d+\.?\d*)(px|em|rem|pt)/g,
function (w, m, u) {
return (m * pixelRatio) + u
}
......@@ -115,12 +116,7 @@ if (pixelRatio !== 1) {
_super.apply(this, args)
this.font = this.font.replace(
/(\d+)(px|em|rem|pt)/g,
function (w, m, u) {
return (m / pixelRatio) + u
}
)
this.font = font
}
})(proto.fillText)
......@@ -134,21 +130,16 @@ if (pixelRatio !== 1) {
args[1] *= pixelRatio // x
args[2] *= pixelRatio // y
this.font = this.font.replace(
/(\d+)(px|em|rem|pt)/g,
var font = this.font
this.font = font.replace(
/(\d+\.?\d*)(px|em|rem|pt)/g,
function (w, m, u) {
return (m * pixelRatio) + u
}
)
_super.apply(this, args)
this.font = this.font.replace(
/(\d+)(px|em|rem|pt)/g,
function (w, m, u) {
return (m / pixelRatio) + u
}
)
this.font = font
}
})(proto.strokeText)
......@@ -168,4 +159,4 @@ export function wrapper (canvas) {
canvas.width = canvas.offsetWidth * pixelRatio
canvas.height = canvas.offsetHeight * pixelRatio
canvas.getContext('2d').__hidpi__ = true
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册