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

Lucida fonts only visible if getAllFonts is called

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • client-libs
    • None
    • 2d
    • x86
    • windows_nt


      I suspect this problem is already known, but since I can't find a specific bug on it,
      I am filing this as P4/S4 for the record.

      We bundle various fonts with the JRE, including "Lucida Sans Regular". It appears
      that by default these fonts are not available through simple calls on the Font
      constructor, but instead you need to first call GraphicsEnviornment.getAllFonts.

      It's not at all obvious from the description of the "Font" constructor that you need
      to call the getAllFonts method in order to make extra fonts accessible. I only
      discovered this by chance. This is likely to be an impediment to anyone actually
      using the Lucida fonts.

      See the test case below. If you run it as "java Test" then it doesn't call getAllFonts
      and it is given Arial when it asks for Lucida. If you run it as "java Test 1" then it
      calls getAllFonts and finds Lucida OK.


      import java.awt.*;

      public class Test extends java.awt.Frame {

          public static void main(String argv[]) {

      Frame frame = new Test();
      frame.setBounds(200,200,200,200);
      frame.show();

      if (argv.length >= 1) {
      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      Font fonts[] = ge.getAllFonts();
      }

      Font f1 = new Font("Lucida Sans Regular", Font.PLAIN, 12);
      System.out.println("f1 = " + f1);
      Font f2 = new Font("Lucida Sans", Font.PLAIN, 12);
      System.out.println("f2 = " + f2);
          }
      }


      graham.hamilton@Eng 1999-01-19

            pkejriwasunw Parry Kejriwal (Inactive)
            ghamiltosunw Graham Hamilton (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: