提交 5b28883d 编写于 作者: Q qiang

fix: 修复 canvas 组件字体部分属性不生效的问题 question/110227

上级 24cf9a76
......@@ -106,7 +106,8 @@ if (pixelRatio !== 1) {
args[1] *= pixelRatio
args[2] *= pixelRatio
var font = this.font
// Safari 重新设置部分属性会导致其他值恢复默认,需获取原始值
var font = this.__font__ || this.font
this.font = font.replace(
/(\d+\.?\d*)(px|em|rem|pt)/g,
function (w, m, u) {
......@@ -130,7 +131,8 @@ if (pixelRatio !== 1) {
args[1] *= pixelRatio // x
args[2] *= pixelRatio // y
var font = this.font
// Safari 重新设置部分属性会导致其他值恢复默认,需获取原始值
var font = this.__font__ || this.font
this.font = font.replace(
/(\d+\.?\d*)(px|em|rem|pt)/g,
function (w, m, u) {
......
......@@ -212,24 +212,21 @@ export default {
data.forEach(function (color_, method_) {
c2d[_[method_]] = _[method_] === 'shadowColor' ? resolveColor(color_) : color_
})
} else {
if (method1 === 'fontSize') {
c2d.font = c2d.font.replace(/\d+\.?\d*px/, data[0] + 'px')
} else {
if (method1 === 'lineDash') {
c2d.setLineDash(data[0])
c2d.lineDashOffset = data[1] || 0
} else {
if (method1 === 'textBaseline') {
if (data[0] === 'normal') {
data[0] = 'alphabetic'
}
c2d[method1] = data[0]
} else {
c2d[method1] = data[0]
}
}
} else if (method1 === 'fontSize') {
const font = c2d.__font__ || c2d.font
c2d.__font__ = c2d.font = font.replace(/\d+\.?\d*px/, data[0] + 'px')
} else if (method1 === 'lineDash') {
c2d.setLineDash(data[0])
c2d.lineDashOffset = data[1] || 0
} else if (method1 === 'textBaseline') {
if (data[0] === 'normal') {
data[0] = 'alphabetic'
}
c2d[method1] = data[0]
} else if (method1 === 'font') {
c2d.__font__ = c2d.font = data[0]
} else {
c2d[method1] = data[0]
}
} else if (method === 'fillPath' || method === 'strokePath') {
method = method.replace(/Path/, '')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册