public class ScaledText extends JFrame
{
public static void main(String[] args)
{
try
{
UIManager.setLookAndFeel
(UIManager.getSystemLookAndFeelClassName());
}
catch (Throwable t)
{
t.printStackTrace();
}
ScaledText text = new ScaledText();
text.show();
}
public ScaledText()
{
setDefaultCloseOperation(EXIT_ON_CLOSE);
Font font1 = new Font("Courier",Font.PLAIN,12);
Font font2 = font1.deriveFont
(AffineTransform.getScaleInstance(1.5,1.5));
Font font3 = font1.deriveFont
(AffineTransform.getScaleInstance(2,2));
JTextField text1 = new JTextField(font1.toString());
text1.setFont(font1);
JTextField text2 = new JTextField(font2.toString());
text2.setFont(font2);
JTextField text3 = new JTextField(font3.toString());
text3.setFont(font3);
XTextField text4 = new XTextField(font1.toString());
text4.setFont(font1);
XTextField text5 = new XTextField(font2.toString());
text5.setFont(font2);
XTextField text6 = new XTextField(font3.toString());
text6.setFont(font3);
Box b = new Box(BoxLayout.Y_AXIS);
b.add(Box.createVerticalStrut(30));
b.add(text1);
b.add(Box.createVerticalStrut(30));
b.add(text2);
b.add(Box.createVerticalStrut(30));
b.add(text3);
b.add(Box.createVerticalStrut(30));
b.add(text4);
b.add(Box.createVerticalStrut(30));
b.add(text5);
b.add(Box.createVerticalStrut(30));
b.add(text6);
getContentPane().add("Center", b);
class XTextField extends JTextField
{
public XTextField(String title)
{
super(title);
}
public void paint(Graphics g)
{
Graphics2D g2d = (Graphics2D)g;
g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_OFF);
super.paint(g2d);
}
}
}
On 29-May-05, at 3:01 PM, Adrian Sutton wrote:
Interesting, thanks for the pointer. There might be a connection,
but this specific bug only exists in Apple's implementation of Java
5; it doesn't exist in Apple's port of 1.4.2_07, and it
doesn't exist
in Sun's implementation on Windows or Linux.
As best I can tell, support for fractional font widths is off by
default
on Windows and thus the bug doesn't show up, but it does exist. The
only reason I discovered it is because in specified JREs on specific
configurations of Solaris 9 (which our client happened to be using)
fractional font metrics support is on by default and thus the bug
shows
up.
From looking at the behavior I'd be extremely surprised if this
were in
fact a different bug. Sadly, the suggested work around (setting the
i18n system property) doesn't appear to have an effect on OS X.
Regards,
Adrian Sutton.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden