@@ -68,7 +68,7 @@ const main = {
68
68
* @param {Object } params
69
69
*/
70
70
drawText ( params ) {
71
- const { x, y, fontSize, color, baseLine, textAlign, text, opacity = 1 , width, lineNum, lineHeight } = params ;
71
+ const { x, y, fontSize, color, baseLine, textAlign, text, opacity = 1 , width, lineNum, lineHeight} = params ;
72
72
if ( Object . prototype . toString . call ( text ) === '[object Array]' ) {
73
73
let preText = { x, y, baseLine } ;
74
74
text . forEach ( item => {
@@ -174,11 +174,12 @@ const handle = {
174
174
* 渲染一段文字
175
175
*/
176
176
_drawSingleText ( { x, y, fontSize, color, baseLine, textAlign = 'left' , text, opacity = 1 , textDecoration = 'none' ,
177
- width, lineNum = 1 , lineHeight = 0 } ) {
177
+ width, lineNum = 1 , lineHeight = 0 , bold = 'normal' , italic = 'normal' , fontFamily = "sans-serif" } ) {
178
178
this . ctx . save ( ) ;
179
179
this . ctx . beginPath ( ) ;
180
+ this . ctx . font = italic + " " + bold + " " + this . toPx ( fontSize ) + "px " + fontFamily
180
181
this . ctx . setGlobalAlpha ( opacity ) ;
181
- this . ctx . setFontSize ( this . toPx ( fontSize ) ) ;
182
+ // this.ctx.setFontSize(this.toPx(fontSize));
182
183
this . ctx . setFillStyle ( color ) ;
183
184
this . ctx . setTextBaseline ( baseLine ) ;
184
185
this . ctx . setTextAlign ( textAlign ) ;
@@ -325,10 +326,10 @@ const helper = {
325
326
} ) ;
326
327
} ,
327
328
toPx ( rpx ) {
328
- return rpx * this . factor ;
329
+ return parseInt ( rpx * this . factor ) ;
329
330
} ,
330
331
toRpx ( px ) {
331
- return px / this . factor ;
332
+ return parseInt ( px / this . factor ) ;
332
333
} ,
333
334
/**
334
335
* 将http转为https
0 commit comments