-
Bug
-
Resolution: Fixed
-
P4
-
8u20
-
OS X Version 10.9.3 (Mavericks), 2.6 Ghz Intel Core i7. MacBook Pro late 2013. 16 GB 1600 Mhz DDR3.
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();
}
}
*** 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();
}
}