加入 fontWeight 属性
This commit is contained in:
parent
c17b06dcd4
commit
b8ffc14965
@ -103,8 +103,11 @@ export default class Painter {
|
||||
let y;
|
||||
let extra;
|
||||
if (view.type === 'text') {
|
||||
const fontWeight = view.css.fontWeight === 'bold' ? 'bold' : 'normal';
|
||||
const fontSize = view.css.fontSize ? view.css.fontSize : '20rpx';
|
||||
this.ctx.font = `normal ${fontWeight} ${fontSize.toPx()}px sans-serif`;
|
||||
this.ctx.setFillStyle(view.css.color ? view.css.color : 'black');
|
||||
this.ctx.setFontSize(view.css.fontSize.toPx());
|
||||
// this.ctx.setFontSize(view.css.fontSize.toPx());
|
||||
const textLength = this.ctx.measureText(view.text).width;
|
||||
width = view.css.width ? view.css.width.toPx() : textLength;
|
||||
// 计算行数
|
||||
|
||||
@ -195,7 +195,7 @@ function setStringPrototype() {
|
||||
|
||||
let res = 0;
|
||||
if (unit === 'rpx') {
|
||||
res = value * screenK;
|
||||
res = Math.round(value * screenK);
|
||||
} else if (unit === 'px') {
|
||||
res = value;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user