0

I have a text editor in my web app that outputs HTML, but a long time ago I had to add a separate line-height parameter that would be sent over an API. As long as this was in pixels I was fine (jQuery's css() function), but now I was asked to give the value in points. Since any conversion between pixels and points depends on DPI, this presents some complications—it's possible to dynamically calculate the DPI and convert, but this seems like a bad method with potential for problems.

The only solution I found was to get the direct style string, something like:

parseInt($('#element')[0].style['line-height']);

However, this doesn't work when no line height is defined.

I can probably set a default line height in points based on the font size (this is what I will do if no better way exists) but I feel that this over-complicates things.

Is there a simple and elegant way to get the current line height value in points using JavaScript/jQuery?

Ynhockey
  • 3,845
  • 5
  • 33
  • 51

0 Answers0