Text Offset Bug

by Eugene Vilder

HTML

<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>

SCSS

#paper {
  border: solid 1px red;
}

JavaScript

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

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

canvas.add(text);

text.__lineHeights[0] = 40;

canvas.renderAll();

text.canvas.renderAll();


/* fabric.Textbox.prototype._getTopOffset = function () {
  return -30;
} */;