From 4a25807866135d3a4f9e3d74303b6fa5066b5fa7 Mon Sep 17 00:00:00 2001 From: CPPAlien Date: Tue, 16 Oct 2018 14:40:48 +0800 Subject: [PATCH] =?UTF-8?q?fontFamily=20=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pen.js b/lib/pen.js index d13f2ba..56c73c5 100644 --- a/lib/pen.js +++ b/lib/pen.js @@ -146,7 +146,7 @@ export default class Painter { case 'text': { const fontWeight = view.css.fontWeight === 'bold' ? 'bold' : 'normal'; view.css.fontSize = view.css.fontSize ? view.css.fontSize : '20rpx'; - this.ctx.font = `normal ${fontWeight} ${view.css.fontSize.toPx()}px sans-serif`; + this.ctx.font = `normal ${fontWeight} ${view.css.fontSize.toPx()}px ${view.css.fontFamily ? view.css.fontFamily : 'sans-serif'}`; // this.ctx.setFontSize(view.css.fontSize.toPx()); const textLength = this.ctx.measureText(view.text).width; width = view.css.width ? view.css.width.toPx() : textLength;