(Macintosh bug # 4127790)
The applet above shows that Serif font works in drawString but not in Labels in Java 1.5 Release 1 on the Macintosh. All is fine in Java 1.4 on Macintosh and other environments (Sun Java 1.5 and Microsoft Java on Windows).
If you have any insights, workarounds or comments about this test page please contact Mickey Segal. A listing of many Java resources is at this link.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class font_fidelity extends Applet {
Label label1, label2, label3;
public void init()
{
setLayout(new GridBagLayout());
setBackground(new Color(225,225, 255));
label1 = new Label("Label in Serif 13");
label1.setFont(new Font("Serif", Font.BOLD, 13));
constrain(this, label1, 0, 0, 1, 1,
GridBagConstraints.NORTHWEST, 0, 0, 0, 0, GridBagConstraints.NONE, 0, 0);
label2 = new Label("Label in SansSerif 13");
label2.setFont(new Font("SansSerif", Font.BOLD, 13));
constrain(this, label2, 0, 1, 1, 1,
GridBagConstraints.NORTHWEST, 0, 0, 0, 0, GridBagConstraints.NONE, 0, 1);
}
static final void constrain(Container container, Component component, int grid_x,
int grid_y,
int grid_width, int grid_height, int anchor, int topPad, int leftPad, int
bottomPad,
int rightPad, int fill, double weightx, double weighty)
{
GridBagConstraints c = new GridBagConstraints();
c.gridx = grid_x;
c.gridy = grid_y;
c.gridwidth = grid_width;
c.gridheight = grid_height;
c.anchor = anchor;
c.insets.top = topPad;
c.insets.left = leftPad;
c.insets.bottom= bottomPad;
c.insets.right = rightPad;
c.fill = fill;
c.weightx = weightx;
c.weighty = weighty;
((GridBagLayout)container.getLayout()).setConstraints(component,
c);
container.add(component);
}
public void paint(Graphics g)
{
g.setFont(new Font("Serif", Font.BOLD, 13));
g.drawString("Paint in Serif 13", 30 , 100);
g.setFont(new Font("SansSerif", Font.BOLD, 13));
g.drawString("Paint in SansSerif 13", 30 , 130);
}
} // END OF Class font_fidelity