Use more accurate metrics when rendering text in java2d
phronmophobic opened this issue · 3 comments
Currently, .getHeight
from FontMetrics is used for line height (see here), but .getHeight
returns an integer which is subtly wrong. Instead, the line height should be calculated using LineMetrics (see here).
This also affects text measurement and text selection.
I'm confused. You say that FontMetrics is used in the java2d backend but I'm still only seeing LineMetrics used there. In searching the repo, I did find a use of FontMetrics in the cljfx backend though.
membrane/src/membrane/cljfx.clj
Line 465 in d319802
Yes, you're right. I guess I was a little too hasty with my diagnosis.
line height decremented in LabelRaw draw
membrane/src/membrane/java2d.clj
Line 280 in 87c8ec2
line height decremented in text-bounds
membrane/src/membrane/java2d.clj
Line 251 in e547cdc
Oh, actually line height is decremented in additional places...