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