Reputation: 160
I've implemented a multiline label by extending a JTextPane. The constructor sets various properties to make it look like a label, including disabling any border/setting margins to 0 which works well.
Environment:
com.jgoodies.looks.windows.WindowsLookAndFeel
L&F (also tested with javax.swing.plaf.metal.MetalLookAndFeel
, same problem)When I increase the font size, the first letter sometimes has "blank space"/a margin of ~1px at 19pt (probably increasing with font size) to its left. This happens at least for letters B, F and L, but certainly not for A. Here's an example:
On the left you can clearly see that the layout looks broken with the title having this weird margin on the left. Please note that the first line with the number (1861) is a regular JLabel.
Zooming in confirms this (the pink line is for illustration):
So from what I can see the typesetting is improper.
Can this be considered a bug in swing? Is there a way to solve this? Eg. is there an easy and clean (ie. not paint()-ing) way to have fine-grained control over typographic features in swing in this context?
EDIT:
This is similar to what I would expect:
vs before:
Upvotes: 4
Views: 105
Reputation: 41188
If you look at your screenshot here:
And in particular look at the 1861...you can see that there is a larger space on both sides of the 1. In particular the gap between 1 and 8 and between 6 and 1 is larger than that between 8 and 6.
That is just how the layout has been arranged on that particular font. They clearly thought that a 1 was getting pushed too close to the characters around it and so they added more space on both sides.
Your options to "fix" this are limited.
i.e.
1861
Baked Beans
dkjfdf skdfjsdlf
Upvotes: 1