Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4076053

Toolkit.getFontList() should not return Helvetica, TimesRoman, Courier fonts

XMLWordPrintable

    • b01
    • x86
    • windows_nt
    • Verified

        The method getFontList() should not return the names of deprecated and proprietary font names.

        The JA local of the JDK also returns the deprecated font names and they are not mapped correctly. In the i18n version, the double byte characters for Helvetica, TimesRoman and Courier are not displayed but the text (??) is displayed in the correct font. These should be mapped according to the JDK documentation.

        The following code shows the fonts returned by getFontList():

        import java.applet.Applet;
        import java.awt.*;
        import java.awt.event.*;

        public class FontListTest extends Applet implements ItemListener {

            private Label sampletext = new Label("Sample Text");
            private Label fontname;
            private List fontlist;
            
            public void init() {
                setLayout(new GridLayout(3, 0));

                fontlist = new List();
                String fontnames[] = Toolkit.getDefaultToolkit().getFontList();
                for (int i = 0; i < fontnames.length; i++)
                    fontlist.add(fontnames[i]);
                    
                fontlist.addItemListener(this);

                add(fontlist);
                add(sampletext);

                fontname = new Label(fontnames[0]);
                add(fontname);
            }

            public void itemStateChanged(ItemEvent e) {
                Font font = new Font(fontlist.getSelectedItem(), Font.PLAIN, 16);
                sampletext.setFont(font);
                fontname.setText(font.toString());
            }
        }

        Notice that
        Helvetica == SansSerif
        TimesRoman == Serif
        Courier == Monospaced

        Also, according to the documentation, the method Font.getFamily() should return the platform specific family name of the font. But in the example, family == name on both platforms. I would expect that for name = SansSerif, family = Arial for Win32, etc,....

              tdv Dmitri Trembovetski (Inactive)
              mdavidsosunw Mark Davidson (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: