So I'm creating an extremely variable interface where even the font almost has to be variable (just trust me, I need it so it works on every resolution) But obviously, there're multiple lines if text, where there is space between the separate lines.
After some trying out I found that the space between a font isn't static (for example, 2 pixels), so it has to be a percentage of the full font (for example, percentage is 25% and the font size is 40 pixels, than the spacing is 10 pixels) or some sort of formula.
After some search work I couldn't find anything about the spacing of a font, so I thought it was Java specific. I doubt this, though. Since Java doesn't have a method where you can change this spacing (as far as I could find).
So my question is, is there any way to either change or get to know the spacing between 2 lines of Times New Roman text?
The biggest problem is that I need to know this to CREATE the font... In case needed the formula: fontSize = (myTextArea.getHeight()-([fontAscend]+[fontDescent])*21)/22
P.S. I'm using a JTextArea and prefer not to use a JEditorPane
Perhaps this is what you're after?
myTextArea.getFontMetrics().getHeight()
getFontMetrics
is a method on JComponent which gives you a FontMetrics
object that has a getHeight()
method.