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

JavaFX font does not load fonts registered through AWT (worked in 1.3, broken in 2.0)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: fx2.0
    • Fix Version/s: None
    • Component/s: javafx
    • Labels:
    • Environment:

      Buggy for me (Windows 7). Not sure the system the above code was executed on.

      Description

      The following code (credited to badgerbadgerbadger on the forum) does not produce an expected behavior.

      java.awt.Font awtFont = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT,
              new File("E:/Java/examples/FRE3OF9X.TTF"));
      GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(awtFont);
      System.out.println("AWT Font:");
      System.out.println(awtFont.getName());
      System.out.println(awtFont.getFamily());
      System.out.println("---------------------");
       
      javafx.scene.text.Font fxFont = new javafx.scene.text.Font(awtFont.getName(), 20);
      System.out.println("FX Font:");
      System.out.println(fxFont.getName());
      System.out.println(fxFont.getFamily());

      The output is:

      AWT Font:
      Free 3 of 9 Extended Regular
      Free 3 of 9 Extended
      ---------------------
      FX Font:
      Free 3 of 9 Extended Regular
      Lucida Sans


      As you see the two outputs should be consistent, but it is not.

        Attachments

          Activity

            People

            Assignee:
            prr Philip Race
            Reporter:
            jforskyjfx Javic Forsky (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: