170

I'm wondering if there's a way to count lines inside a div for example. Say we have a div like so:

<div id="content">hello how are you?</div>

Depending on many factors, the div can have one, or two, or even four lines of text. Is there any way for the script to know?

In other words, are automatic breaks represented in DOM at all?

1

21 Answers 21

125

If the div's size is dependent on the content (which I assume to be the case from your description) then you can retrieve the div's height using:

var divHeight = document.getElementById('content').offsetHeight;

And divide by the font line height:

document.getElementById('content').style.lineHeight;

Or to get the line height if it hasn't been explicitly set:

var element = document.getElementById('content');
document.defaultView.getComputedStyle(element, null).getPropertyValue("lineHeight");

You will also need to take padding and inter-line spacing into account.

EDIT

Fully self-contained test, explicitly setting line-height:

function countLines() {
   var el = document.getElementById('content');
   var divHeight = el.offsetHeight
   var lineHeight = parseInt(el.style.lineHeight);
   var lines = divHeight / lineHeight;
   alert("Lines: " + lines);
}
<body onload="countLines();">
  <div id="content" style="width: 80px; line-height: 20px">
    hello how are you? hello how are you? hello how are you? hello how are you?
  </div>
</body>

10
  • 11
    It's a good start except that the line-height may not always have been set. You should get that from computed style of the element.
    – Chetan S
    Apr 23, 2009 at 23:17
  • 1
    On second thoughts, the line-height need not always be numeric (or in pixels). So if your code relies on it and your CSS convention permits it, you should probably set a line height in pixels.
    – Chetan S
    Apr 23, 2009 at 23:35
  • 6
    @Chetan - setting text dimensions in pixels is generally considered a bad thing. astahost.com/Sizes-Webdesign-Em-Vs-Px-t8926.html
    – annakata
    Apr 24, 2009 at 8:35
  • 6
    This may only work in simplest case (like my example). If there are spans inside, inline-block elements and so on, straightforward division by (parent) font-size is worthless. Still, it is better than nothing, thanks.
    – buti-oxa
    Apr 24, 2009 at 16:38
  • 4
    I think a better method of getting a computed line-height (that isn't explicitly set) would be to use window.getComputedStyle(element, null).getPropertyValue('line-height')
    – rnevius
    Oct 9, 2015 at 19:07
46

Check out the function getClientRects() which can be used to count the number of lines in an element. Here is an example of how to use it.

var message_lines = $("#message_container")[0].getClientRects();

It returns a javascript DOM object. The amount of lines can be known by doing this:

var amount_of_lines = message_lines.length;

A few things to note is it only works if the containing element is inline, however you can surround the containing inline element with a block element to control the width like so:

console.log(  message_container.getClientRects().length  )
<div style="display:inline;" id="message_container">
  ..Text of the post..<br>
  nice ha?
</div>

Though I don't recommend hard coding the style like that. It's just for example purposes.

7
  • 6
    This and the other getClientRects-based answer are far better than the accepted one
    – matteo
    Apr 20, 2016 at 16:35
  • 6
    getClientRects().length always returns 1 for me in Opera and Chrome
    – klm123
    May 14, 2021 at 10:28
  • 6
    @klm123 You need to set the element to display: inline
    – Tofandel
    Jun 4, 2021 at 12:43
  • 1
    Adding to this, if you need to find the number of lines when there are nested elements (a,strong etc) try this codesandbox.io/s/adoring-wind-v6s6h
    – Akshay
    Aug 10, 2021 at 5:32
  • 1
    @Akshay's answer is better and works for simple cases, but it breaks if the nested inline elements are not the same height as the rest of the line. For example, try adding a padding around the "a" in the example, and the line count detection algorithm breaks. Nov 20, 2022 at 1:00
22

One solution is to enclose every word in a span tag using script. Then if the Y dimension of a given span tag is less than that of it's immediate predecessor then a line break has occurred.

3
  • Clever! How do you do that? I guess you assume text only paragraph (as I have in the example). I did not have this limitation in mind, but it may be OK, provided the script does not crash when there is something else inside the paragraph.
    – buti-oxa
    Jan 11, 2010 at 15:51
  • 2
    On second thought, this method fails if there are vertically aligned spans in the line. So, even text only paragraph may be counted wrongly.
    – buti-oxa
    Jan 12, 2010 at 16:00
  • My div has text and images... luckily the images are absolutely positioned so I think they would be excluded. :D Anyways I used the same code you suggested but with a div not a span, thank you though +1! Jan 16, 2013 at 16:42
20

I wasnt satisfied with the answers here and on other questions. The highest rated answer doesn't take padding or border into account, and therefore obviously ignores box-sizing as well. My answer combines some techniques here and and on other threads to get a solution that works to my satisfaction.

It isnt perfect: When no numerical value was able to be retrieved for the line-height (e.g. normal or inherit), it just uses the font-size multiplied by 1.2. Perhaps someone else can suggest a reliable way to detect the pixel value in those cases.

Other than that, it has been able to correctly handle most of the styles and cases I have thrown at it.

jsFiddle for playing around and testing. Also inline below.

function countLines(target) {
  var style = window.getComputedStyle(target, null);
  var height = parseInt(style.getPropertyValue("height"));
  var font_size = parseInt(style.getPropertyValue("font-size"));
  var line_height = parseInt(style.getPropertyValue("line-height"));
  var box_sizing = style.getPropertyValue("box-sizing");
  
  if(isNaN(line_height)) line_height = font_size * 1.2;
 
  if(box_sizing=='border-box')
  {
    var padding_top = parseInt(style.getPropertyValue("padding-top"));
    var padding_bottom = parseInt(style.getPropertyValue("padding-bottom"));
    var border_top = parseInt(style.getPropertyValue("border-top-width"));
    var border_bottom = parseInt(style.getPropertyValue("border-bottom-width"));
    height = height - padding_top - padding_bottom - border_top - border_bottom
  }
  var lines = Math.ceil(height / line_height);
  alert("Lines: " + lines);
  return lines;
}
countLines(document.getElementById("foo"));
div
{
  padding:100px 0 10% 0;
  background: pink;
  box-sizing: border-box;
  border:30px solid red;
}
<div id="foo">
x<br>
x<br>
x<br>
x<br>
</div>

1
  • Good consideration, but in my case the height of one line div is more than line height by 1px, without any padding and border. So getting the line height by combing your answer and @e-info128's answer (cloneNode method) may be a better choice
    – Eric
    Mar 9, 2018 at 11:28
11

Clone the container object and write 2 letters and calculate the height. This return the real height with all style applied, line height, etc. Now, calculate the height object / the size of a letter. In Jquery, the height excelude the padding, margin and border, it is great to calculate the real height of each line:

other = obj.clone();
other.html('a<br>b').hide().appendTo('body');
size = other.height() / 2;
other.remove();
lines = obj.height() /  size;

If you use a rare font with different height of each letter, this does not works. But works with all normal fonts, like Arial, mono, comics, Verdana, etc. Test with your font.

Example:

<div id="content" style="width: 100px">hello how are you? hello how are you? hello how are you?</div>
<script type="text/javascript">
$(document).ready(function(){

  calculate = function(obj){
    other = obj.clone();
    other.html('a<br>b').hide().appendTo('body');
    size = other.height() / 2;
    other.remove();
    return obj.height() /  size;
  }

  n = calculate($('#content'));
  alert(n + ' lines');
});
</script>

Result: 6 Lines

Works in all browser without rare functions out of standards.

Check: https://jsfiddle.net/gzceamtr/

3
  • First of all, I want to say thank you very much, just what I was looking for. Could you please explain each line of the calculate function. Thanks a lot in advance. SYA :)
    – LebCit
    May 4, 2017 at 23:48
  • 3
    for those who need non-jQuery answer: clone→cloneNode, hide→style.visibility = "hidden", html('a<br>b')→textContent='a\r\nb', appendTo('body')→document.documentElement.appendChild, height()→getBoundingClientRect().height
    – Eric
    Mar 9, 2018 at 11:37
  • Since i get error of 1px between line height and div height, I recommend this answer. Combining this and @Jeff's answer will be even better
    – Eric
    Mar 9, 2018 at 11:41
9

For those who use jQuery http://jsfiddle.net/EppA2/3/

function getRows(selector) {
    var height = $(selector).height();
    var line_height = $(selector).css('line-height');
    line_height = parseFloat(line_height)
    var rows = height / line_height;
    return Math.round(rows);
}
2
  • jsfiddle.net/EppA2/9 is less accurate, but according to this may be better supported by various browsers
    – penkovsky
    Feb 16, 2013 at 19:36
  • 9
    When jQuery returns "normal" from $(selector).css('line-height');, you won't get a number out of that function.
    – bafromca
    Apr 9, 2014 at 22:40
8

I am convinced that it is impossible now. It was, though.

IE7’s implementation of getClientRects did exactly what I want. Open this page in IE8, try refreshing it varying window width, and see how number of lines in the first element changes accordingly. Here’s the key lines of the javascript from that page:

var rects = elementList[i].getClientRects();
var p = document.createElement('p');
p.appendChild(document.createTextNode('\'' + elementList[i].tagName + '\' element has ' + rects.length + ' line(s).'));

Unfortunately for me, Firefox always returns one client rectangle per element, and IE8 does the same now. (Martin Honnen’s page works today because IE renders it in IE compat view; press F12 in IE8 to play with different modes.)

This is sad. It looks like once again Firefox’s literal but worthless implementation of the spec won over Microsoft’s useful one. Or do I miss a situation where new getClientRects may help a developer?

2
  • 3
    As pointed out by Mozilla's element.getClientRects documentation, at least for inline elements the W3C spec does result in a rect for each line of text — not ideal, but something at least.
    – natevw
    Mar 21, 2012 at 20:27
  • getClientRects().length is the correct way. getComputedStyle() may return values like "inherit", "normal" and "auto".
    – Binyamin
    Oct 2, 2016 at 7:20
6

based on GuyPaddock's answer from above, this seems to work for me

function getLinesCount(element) {
  var prevLH = element.style.lineHeight;
  var factor = 1000;
  element.style.lineHeight = factor + 'px';

  var height = element.getBoundingClientRect().height;
  element.style.lineHeight = prevLH;

  return Math.floor(height / factor);
}

the trick here is to increase the line-height so much that it will "swallow" any browser / OS differences in the way that they render fonts

Checked it with various stylings and different font sizes / families only thing that it doesn't take into account (since in my case it didnt matter), is the padding - which can easily be added to the solution.

3

No, not reliably. There are simply too many unknown variables

  1. What OS (different DPIs, font variations, etc...)?
  2. Do they have their font-size scaled up because they are practically blind?
  3. Heck, in webkit browsers, you can actually resize textboxes to your heart's desire.

The list goes on. Someday I hope there will be such a method of reliably accomplishing this with JavaScript, but until that day comes, your out of luck.

I hate these kinds of answers and I hope someone can prove me wrong.

2
  • 4
    If you count the lines after rendering, all those unknowns are irrelevant. Your point applies, of course, if you try to "guesstimate" how many lines the browser use when rendering the text.
    – simon
    Dec 5, 2013 at 12:21
  • I'd say the variable of users zooming in and/or changing text size can be ignored. I have never ever seen a site that has it's design optimized to accomodate for window scaling (after page being loaded) or changing text size browser-wise, so I don't think those are important factors in this specific question. However I agree there are no reliable solutions, just the "guesstimations" based on pixels as other people pointed out.
    – Kalko
    Sep 5, 2016 at 13:15
2

Try this solution:

function calculateLineCount(element) {
  var lineHeightBefore = element.css("line-height"),
      boxSizing        = element.css("box-sizing"),
      height,
      lineCount;

  // Force the line height to a known value
  element.css("line-height", "1px");

  // Take a snapshot of the height
  height = parseFloat(element.css("height"));

  // Reset the line height
  element.css("line-height", lineHeightBefore);

  if (boxSizing == "border-box") {
    // With "border-box", padding cuts into the content, so we have to subtract
    // it out
    var paddingTop    = parseFloat(element.css("padding-top")),
        paddingBottom = parseFloat(element.css("padding-bottom"));

    height -= (paddingTop + paddingBottom);
  }

  // The height is the line count
  lineCount = height;

  return lineCount;
}

You can see it in action here: https://jsfiddle.net/u0r6avnt/

Try resizing the panels on the page (to make the right side of the page wider or shorter) and then run it again to see that it can reliably tell how many lines there are.

This problem is harder than it looks, but most of the difficulty comes from two sources:

  1. Text rendering is too low-level in browsers to be directly queried from JavaScript. Even the CSS ::first-line pseudo-selector doesn't behave quite like other selectors do (you can't invert it, for example, to apply styling to all but the first line).

  2. Context plays a big part in how you calculate the number of lines. For example, if line-height was not explicitly set in the hierarchy of the target element, you might get "normal" back as a line height. In addition, the element might be using box-sizing: border-box and therefore be subject to padding.

My approach minimizes #2 by taking control of the line-height directly and factoring in the box sizing method, leading to a more deterministic result.

2

My solution(may be duplicated): make this element nowrap to calculate lineHeight, then calculate lineNumber by oneLineHeight / lineHeight

function getLineInfo(root: HTMLElement): {
  lineNumber: number;
  lineHeight: number;
  elHeight: number;
} {
  const oldOverFlow = root.style.overflow;
  const oldWhiteSpace = root.style.whiteSpace;

  root.style.overflow = "hidden";
  root.style.whiteSpace = "nowrap";

  const lineHeight = root.offsetHeight;
  root.style.overflow = oldOverFlow;
  root.style.whiteSpace = oldWhiteSpace;

  const lineNumber = Math.round(root.offsetHeight / lineHeight);

  return {
    lineNumber: lineNumber,
    lineHeight,
    elHeight: root.offsetHeight,
  };
}
1

You should be able to split('\n').length and get the line breaks.

update: this works on FF/Chrome but not IE.

<html>
<head>
<script src="jquery-1.3.2.min.js"></script>
<script>
    $(document).ready(function() {
        var arr = $("div").text().split('\n');
        for (var i = 0; i < arr.length; i++)
            $("div").after(i + '=' + arr[i] + '<br/>');
    });
</script>
</head>
<body>
<div>One
Two
Three</div>
</body>
</html>
3
  • 1
    Try it and let us know how that goes. I'm dead serious, not being sarcastic. You can use this code in FireBug's console on this very page. var the_text = $('.welovestackoverflow p').text(); var numlines = the_text.split("\n").length; alert(numlines);
    – KyleFarris
    Apr 24, 2009 at 4:43
  • 3
    Thanks for this surprize, I did not know it is possible, but this is not what I want. Jquery seems to count hard line breaks in the source, and I am interested in automatic line breaks in the result. In the case of your "One Two Three" div, the result should be 1, because browser put all text into one line.
    – buti-oxa
    Apr 24, 2009 at 16:30
  • Then I misunderstood your question. You want to find the computed line-height then.
    – Chad Grant
    Apr 26, 2009 at 2:13
1

getClientRects return the client rects like this and if you want to get the lines, use the follow function like this

function getRowRects(element) {
    var rects = [],
        clientRects = element.getClientRects(),
        len = clientRects.length,
        clientRect, top, rectsLen, rect, i;

    for(i=0; i<len; i++) {
        has = false;
        rectsLen = rects.length;
        clientRect = clientRects[i];
        top = clientRect.top;
        while(rectsLen--) {
            rect = rects[rectsLen];
            if (rect.top == top) {
                has = true;
                break;
            }
        }
        if(has) {
            rect.right = rect.right > clientRect.right ? rect.right : clientRect.right;
            rect.width = rect.right - rect.left;
        }
        else {
            rects.push({
                top: clientRect.top,
                right: clientRect.right,
                bottom: clientRect.bottom,
                left: clientRect.left,
                width: clientRect.width,
                height: clientRect.height
            });
        }
    }
    return rects;
}
1

I found a way to calc the line number when I develop a html editor. The primary method is that:

  1. In IE you can call getBoundingClientRects, it returns each line as a rectangle

  2. In webkit or new standard html engine, it returns each element or node's client rectangles, in this case you can compare each rectangles, I mean each there must be a rectangle is the largest, so you can ignore those rectangles that height is smaller(if there is a rectangle's top smaller than it and bottom larger than it, the condition is true.)

so let's see the test result:

enter image description here

The green rectangle is the largest rectangle in each row

The red rectangle is the selection boundary

The blue rectangle is the boundary from start to selection after expanding, we see it may larger than red rectangle, so we have to check each rectangle's bottom to limit it must smaller than red rectangle's bottom.

        var lineCount = "?";
        var rects;
        if (window.getSelection) {
            //Get all client rectangles from body start to selection, count those rectangles that has the max bottom and min top
            var bounding = {};
            var range = window.getSelection().getRangeAt(0);//As this is the demo code, I dont check the range count
            bounding = range.getBoundingClientRect();//!!!GET BOUNDING BEFORE SET START!!!

            //Get bounding and fix it , when the cursor is in the last character of lineCount, it may expand to the next lineCount.
            var boundingTop = bounding.top;
            var boundingBottom = bounding.bottom;
            var node = range.startContainer;
            if (node.nodeType !== 1) {
                node = node.parentNode;
            }
            var style = window.getComputedStyle(node);
            var lineHeight = parseInt(style.lineHeight);
            if (!isNaN(lineHeight)) {
                boundingBottom = boundingTop + lineHeight;
            }
            else {
                var fontSize = parseInt(style.fontSize);
                if (!isNaN(fontSize)) {
                    boundingBottom = boundingTop + fontSize;
                }
            }
            range = range.cloneRange();

            //Now we have enougn datas to compare

            range.setStart(body, 0);
            rects = range.getClientRects();
            lineCount = 0;
            var flags = {};//Mark a flags to avoid of check some repeat lines again
            for (var i = 0; i < rects.length; i++) {
                var rect = rects[i];
                if (rect.width === 0 && rect.height === 0) {//Ignore zero rectangles
                    continue;
                }
                if (rect.bottom > boundingBottom) {//Check if current rectangle out of the real bounding of selection
                    break;
                }
                var top = rect.top;
                var bottom = rect.bottom;
                if (flags[top]) {
                    continue;
                }
                flags[top] = 1;

                //Check if there is no rectangle contains this rectangle in vertical direction.
                var succ = true;
                for (var j = 0; j < rects.length; j++) {
                    var rect2 = rects[j];
                    if (j !== i && rect2.top < top && rect2.bottom > bottom) {
                        succ = false;
                        break;
                    }
                }
                //If succ, add lineCount 1
                if (succ) {
                    lineCount++;
                }
            }
        }
        else if (editor.document.selection) {//IN IE8 getClientRects returns each single lineCount as a rectangle
            var range = body.createTextRange();
            range.setEndPoint("EndToEnd", range);
            rects = range.getClientRects();
            lineCount = rects.length;
        }
        //Now we get lineCount here
1

Following @BobBrunius 2010 suggestion I created this with jQuery. No doubt it could be improved but it may help some.

$(document).ready(function() {

  alert("Number of lines: " + getTextLinesNum($("#textbox")));

});

function getTextLinesNum($element) {

  var originalHtml = $element.html();
  var words = originalHtml.split(" ");
  var linePositions = [];
        
  // Wrap words in spans
  for (var i in words) {
    words[i] = "<span>" + words[i] + "</span>";
  }
        
  // Temporarily replace element content with spans. Layout should be identical.
  $element.html(words.join(" "));
        
  // Iterate through words and collect positions of text lines
  $element.children("span").each(function () {
    var lp = $(this).position().top;
    if (linePositions.indexOf(lp) == -1) linePositions.push(lp);
  });
        
  // Revert to original html content
  $element.html(originalHtml);
        
  // Return number of text lines
  return linePositions.length;

}
#textbox {
  width: 200px;
  text-align: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<div id="textbox">Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
  <br>sed diam nonummy</div>

1

In certain cases, like a link spanning over multiple rows in non justified text, you can get the row count and every coordinate of each line, when you use this:

var rectCollection = object.getClientRects();

https://developer.mozilla.org/en-US/docs/Web/API/Element/getClientRects

This works because each line would be different even so slightly. As long as they are, they are drawn as a different "rectangle" by the renderer.

1

You can compare element height and element height with line-height: 0

function lineCount(elm) {
      const originalStyle = elm.getAttribute('style')
      
      // normalize 
      elm.style.padding = 0
      elm.style.border = 0
      
      // measure
      elm.style.lineHeight = 1
      const totalHeight = elm.offsetHeight
      elm.style.lineHeight = 0
      const singleLineHeight = elm.scrollHeight * 2
      
      const lineCount = Math.round(totalHeight / singleLineHeight)
      
      // undo above style changes
      elm.setAttribute('style', originalStyle)
      
      return (isNaN(lineCount) || singleLineHeight == 0) ? 0 : lineCount
}

function printElmLineCount(elm){
  console.log(
     lineCount(elm)
  )
}
p{ border:2em black solid ; padding:1em; line-height: 3em; }
<p contentEditable id='elm'>
  one<br>
  two<br>
  three
</p>

<button onclick='printElmLineCount(elm)'>Get lines count</button>

1
  • Not work if exist class. To fix this, i've added: const originalClass = elm.className; and undo with elm.setAttribute('class', originalClass) May 31, 2022 at 9:28
1

Easiest way to do this is calculating line height and divide it by element height. This code works for any Kind of elements:

function getStyle(el,styleProp)
{
    var x = el;
    if (x.currentStyle)
        var y = x.currentStyle[styleProp];
    else if (window.getComputedStyle)
        var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
    return y;
}
function calculateLineHeight (element) {

  var lineHeight = parseInt(getStyle(element, 'line-height'), 10);
  var clone;
  var singleLineHeight;
  var doubleLineHeight;

  if (isNaN(lineHeight)) {
    clone = element.cloneNode();
    clone.innerHTML = '<br>';
    element.appendChild(clone);
    singleLineHeight = clone.offsetHeight;
    clone.innerHTML = '<br><br>';
    doubleLineHeight = clone.offsetHeight;
    element.removeChild(clone);
    lineHeight = doubleLineHeight - singleLineHeight;
  }

  return lineHeight;
}

function getNumlines(el){return Math.ceil(el.offsetHeight / calculateLineHeight (el))}



console.log(getNumlines(document.getElementById('g1')))
.Text{font-size: 28px;}
@media screen and (max-width: 780px) {
            .Text{font-size: 50px;}
        }
<div><span class="Text" id="g1" >
                This code works for any Kind of elements: bla blo bli bla blo bli bla blo bli bla blo bli bla blo bli bla blo bli bla blo bli bla blo bli bla blo bli bla blo bli bla blo bli bla blo bli bla blo bli bla blo bli bla blo bli bla blo bli bla blo bli bla blo bli bla blo bli </span>
        </div>

0

You could count the number of line breaks in the element's innerText, like this:

const text = anyDivElement.innerText;
const lines = text.split(/\r\n|\r|\n/).length;
0

Another simple solution, by using getClientRects(), not well tested:

export function getLineInfo(root: HTMLElement): {
  lineNumber: number;
  lineHeight: number;
  elHeight: number;
} {
  const test = document.createElement("span");
  test.textContent = " ";

  root.appendChild(test);
  const first = test.getClientRects();
  root.insertBefore(test, root.firstChild);
  const second = test.getClientRects();

  const lineHeight = first[0].y - second[0].y;

  test.remove();

  const lastPadding = lineHeight - first[0].height;
  const offsetHeight = first[0].bottom - second[0].top + lastPadding;

  const lineNumber = Math.round(offsetHeight / lineHeight);

  return {
    lineNumber: lineNumber,
    lineHeight,
    elHeight: offsetHeight,
  };
}
0

For React and Next.js i create my personal util archive count-lines-element.ts

export function countLines(id: string) {

    if (!process.browser || !window || !id) {
      return 0;
    }

    const target = document.getElementById(id);

    if(!target) {
      return 0
    }

    var style = window.getComputedStyle(target, null);
    var height = parseInt(style.getPropertyValue("height"));
    var font_size = parseInt(style.getPropertyValue("font-size"));
    var line_height = parseInt(style.getPropertyValue("line-height"));
    var box_sizing = style.getPropertyValue("box-sizing");

    if (isNaN(line_height)) line_height = font_size * 1.2;

    if (box_sizing == "border-box") {
      var padding_top = parseInt(style.getPropertyValue("padding-top"));
      var padding_bottom = parseInt(style.getPropertyValue("padding-bottom"));
      var border_top = parseInt(style.getPropertyValue("border-top-width"));
      var border_bottom = parseInt(
        style.getPropertyValue("border-bottom-width")
      );
      height =
        height - padding_top - padding_bottom - border_top - border_bottom;
    }
    var lines = Math.ceil(height / line_height);

    return lines;
  }```
1
  • 1
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Aug 12, 2023 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.