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

[Font] Two Font.loadFont calls on OSX returns null second time a font is loaded

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u20
    • Fix Version/s: 8u20
    • Component/s: javafx
    • Labels:
    • Environment:

      OS X Version 10.9.3 (Mavericks), 2.6 Ghz Intel Core i7. MacBook Pro late 2013. 16 GB 1600 Mhz DDR3.

      Description

      On OSX (tested on Windows 7 x64 and works fine there), if a font is loaded twice via Font.loadFont() the second call will return null. The API for Font.loadFont() says a successfully loaded font will be registered with the subsystem but it does not say that a second call to loadFont may not be successful at all and return null. (And as pointed out, on Windows this is not an issue.)

      *** Output of below code on OSX ****

      Font load 1 is: Font[name=BebasNeue, family=Bebas Neue, style=Regular, size=18.0]
      Font load 2 is: null

      *** OTF Font used in test code ***
      http://www.fontsquirrel.com/fonts/bebas-neue

      *** Test code (ensure path to font matches your setup) ****

      package testing;

      import javafx.application.Application;
      import javafx.application.Platform;
      import javafx.scene.text.Font;
      import javafx.stage.Stage;

          /**
           * Problem class to show the issue of Font.loadFont() on OSX
           */
          public class FXProblem extends Application
          {
              /**
               * {@inheritDoc}
               */
              @Override
              public void start(final Stage stage) throws Exception
              {
           Font f1 = Font.loadFont(FXProblem.class.getResource("/fonts/BebasNeue.otf").toExternalForm(), 18);
           Font f2 = Font.loadFont(FXProblem.class.getResource("/fonts/BebasNeue.otf").toExternalForm(), 18);
           System.out.println("Font load 1 is: " + f1);
           System.out.println("Font load 2 is: " + f2);
          
           Platform.exit();
           System.exit(0);
              }

              /**
               * Main.
               */
              public static void main(final String[] args)
              {
                  launch();
              }
          }

        Attachments

          Activity

            People

            Assignee:
            fheidric Felipe Heidrich (Inactive)
            Reporter:
            ecrumhornjfx Emil Crumhorn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: