EDIT: The lid height was what I was looking for. See Accepted Answer.
After you made your way through the PDFBox source, I found that this should do the trick of calculating the font height.
int fontSize = 14; PDFont font = PDType1Font.HELVETICA; font.getFontDescriptor().getFontBoundingBox().getHeight() / 1000 * fontSize
The method is not perfect. If you draw a rectangle with a height of 200 and Y with a font size of 200, you will get a font height of 231.2 calculated using the method described above, even if it is actually printed smaller than the rectangle.
Each font has a different error, but with helvetica it is too close to 13.5 percent, regardless of font size. So to get the right font height for helvetica, this works ...
font.getFontDescriptor().getFontBoundingBox().getHeight() / 1000 * fontSize * 0.865
source share