【发布时间】:2016-04-26 09:55:01
【问题描述】:
我正在使用此代码使用fabric js 在canvas 中添加textbox,
var text = 'Type Text Here';
var textSample = new fabric.Textbox(text, {
left: getCardLeft() + 100,
top: getCardTop() + 10,
width: 200,
height: 20,
fontFamily: 'Helvetica',
fill: getColorPickerForegroundColor(),
fontWeight: '',
fontSize: parseInt('25'),
originX: 'center',
hasRotatingPoint: true,
centerTransform: true,
});
canvas.add(textSample);
成功地将textbox 添加到canvas。
现在,如果我尝试使用此命令使其 bold
canvas.getActiveObject().set("fontWeight", "bold");
canvas.renderAll();
工作,但是当尝试将其更改为正常时,
canvas.getActiveObject().set("fontWeight", "");
canvas.getActiveObject().set("fontWeight", "100");
canvas.getActiveObject().set("fontWeight", "normal");
canvas.renderAll();
不工作。
我不知道问题出在哪里。我在这里做错了吗?。
它的行为很奇怪 你可以看到它here。
【问题讨论】:
标签: javascript fabricjs