有没有办法在Kinetic.Text(KineticJS)中设置字体权重?

Mar*_*arc 3 kineticjs

有没有办法在KineticJS的Text对象中设置font-weight?

这是示例代码:

  var myText = new Kinetic.Text(
  {
    x: 350,
    y: 50,
    text: 'OK',
    fontSize: 18,
    fontFamily: 'Verdana',
    fill: 'white'
  });
Run Code Online (Sandbox Code Playgroud)

我希望font-weight为100或200,而不是默认值(400).在文档中找不到fontWeight属性,我尝试了以下但没有成功:

  • 使用fontStyle属性(允许您特定粗体,正常,斜体)
  • 设置id属性并尝试通过CSS设置font-weight.

谢谢你的任何提示.

mar*_*rkE 5

使用fontStyle属性(提示:值必须是字符串 - 而不是数字):

var myText = new Kinetic.Text({
    x:100,
    y:100,
    text:"Hello World!",
    fill: 'red',
    fontFamily:"Calibri",
    fontSize:18,
    fontStyle:"100"
});
Run Code Online (Sandbox Code Playgroud)