简体   繁体   English

Fabric.js 中特定字符的文本高度

[英]Text height of specific character in Fabric.js

I have a text object in fabric.js that I am creating with:我在fabric.js中有一个文本对象,我正在创建它:

     fbText = new fabric.Textbox('@TEST', {
      width: 700,
      fill: '#303846',
      top: 150,
      left: 50,
      fontSize: 150,
      textAlign: 'left',
      fixedWidth: 700,
    // fontWeight: 'bold',
      editable: false,
      originY: 'center',
     styles: {
      // first word of text i.e Test
      0: {
        //first letter of first word i.e T
        0: { fill: '#21bba6', fontSize: 130}
      },
    }
  })

I would like to make the 1st letter higher than the rest of the word.我想让第一个字母高于单词的其余部分。 Any thoughts on how that might be possible?关于这怎么可能的任何想法?

This is what I want to happen:这就是我想要发生的事情:

在此处输入图片说明

This is currently happening:这是目前正在发生的:

这就是正在发生的事情

You can use deltaY negative value.您可以使用deltaY负值。 There are more available style properties that can be used, have a look at [ http://fabricjs.com/docs/fabric.Textbox.html#_styleProperties][1] .有更多可用的样式属性可以使用,请查看 [ http://fabricjs.com/docs/fabric.Textbox.html#_styleProperties][1]

var fbText = new fabric.Textbox('@TEST', {
    ...,
    styles: {
        0: {
            0: { 
                fill: '#21bba6', 
                fontSize: 130,
                deltaY: -30
            }
        },
    }
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM