gpt4 book ai didi

javascript - fabric js 字体粗细不工作

转载 作者:可可西里 更新时间:2023-11-01 01:19:09 25 4
gpt4 key购买 nike

我正在使用此代码使用 fabric jscanvas 中添加 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 中。现在,如果我尝试使用此命令使其成为粗体

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

最佳答案

我只是从 here 中获取 fabric.js并替换为我的,并且全部工作。

关于javascript - fabric js 字体粗细不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34901979/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com