From 709c74c01ebcf5a1fc60a30968c4f764b12db35a Mon Sep 17 00:00:00 2001 From: w157020087 <157020087@qq.com> Date: Fri, 18 Mar 2022 10:16:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B0=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/painter.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib/painter.js b/src/lib/painter.js index 132b5e0..a610c73 100644 --- a/src/lib/painter.js +++ b/src/lib/painter.js @@ -577,6 +577,14 @@ export default class Painter { } else { this.ctx.fillText(text, x, y, measuredWith) } + // 新增textStroke属性 文字周围白色阴影 + if (view.css.textStyle === 'textStroke') { + this.ctx.lineWidth = 15; + this.ctx.strokeStyle = "#FFFFFF"; + this.ctx.strokeText(text, x, y,measuredWith); + this.ctx.fillStyle = "#1D338C"; + this.ctx.fillText(text, x, y,measuredWith); + } const fontSize = view.css.fontSize.toPx() if (view.css.textDecoration) { this.ctx.lineWidth = fontSize / 13 @@ -593,6 +601,12 @@ export default class Painter { this.ctx.moveTo(lineX, y - fontSize / 3) this.ctx.lineTo(lineX + measuredWith, y - fontSize / 3) } + // 内容下划线下边距离属性 防止内容下划线贴到字的最底下 + if (/\bunderlineBottom\b/.test(view.css.textDecoration)) { + this.ctx.lineWidth = 3 + this.ctx.moveTo(x, y + 12) + this.ctx.lineTo(x + measuredWith, y + 12) + } this.ctx.closePath() this.ctx.strokeStyle = view.css.color this.ctx.stroke()