Merge pull request #202 from Kujiale-Mobile/heidao

fix: 修复textDecoration相关问题
This commit is contained in:
Chris 2019-11-29 14:59:30 +08:00 committed by GitHub
commit 0fb26a323c

View File

@ -518,9 +518,11 @@ export default class Painter {
this.ctx.fillText(text, x, y, measuredWith); this.ctx.fillText(text, x, y, measuredWith);
} }
if (view.css.textDecoration) { if (view.css.textDecoration) {
const fontSize = view.css.fontSize.toPx();
this.ctx.lineWidth = fontSize / 13;
this.ctx.beginPath(); this.ctx.beginPath();
this.ctx.moveTo(...this.callbackInfo.textDecoration.moveTo); this.ctx.moveTo(...this.movingCache.textDecoration.moveTo);
this.ctx.lineTo(...this.callbackInfo.textDecoration.lineTo); this.ctx.lineTo(...this.movingCache.textDecoration.lineTo);
this.ctx.closePath(); this.ctx.closePath();
this.ctx.strokeStyle = view.css.color; this.ctx.strokeStyle = view.css.color;
this.ctx.stroke(); this.ctx.stroke();
@ -612,6 +614,7 @@ export default class Painter {
} }
const fontSize = view.css.fontSize.toPx(); const fontSize = view.css.fontSize.toPx();
if (view.css.textDecoration) { if (view.css.textDecoration) {
this.ctx.lineWidth = fontSize / 13;
this.ctx.beginPath(); this.ctx.beginPath();
if (/\bunderline\b/.test(view.css.textDecoration)) { if (/\bunderline\b/.test(view.css.textDecoration)) {
this.ctx.moveTo(lineX, y); this.ctx.moveTo(lineX, y);