如何在FabricJS中消除第一行的间隙

时间:2019-10-10 18:39:16

标签: fabricjs fabricjs2

有没有一种方法可以消除第一行文字的空白? 基本上,我希望B触摸顶部边框(蓝线)。

enter image description here

https://jsfiddle.net/redlive/ksc0rf8x/

const canvas = new fabric.Canvas('paper');

const text = new fabric.Textbox("Beach", {
    left: 50,
    top: 50,
    width: 50,
    height: 50,
    fontSize: 40,
    lineHeight: 0.8,
    textBackgroundColor: "red",
    fill: "white"
});

canvas.add(text);
canvas.renderAll();

text.canvas.renderAll();
#paper {
  border: solid 1px red;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/2.3.0/fabric.js"></script>
<canvas id="paper" width="400" height="400" style="border:1px solid #ccc"></canvas>

0 个答案:

没有答案