首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >fabric js fontweight不工作

fabric js fontweight不工作
EN

Stack Overflow用户
提问于 2016-01-20 21:55:23
回答 2查看 2.6K关注 0票数 17

我正在使用此代码在canvas中使用fabric js添加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

先访问here,然后访问here

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34901979

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档