I load a custom true type font from my jar and in 8u20 it no longer loads in Linux. I believe this is because of the change to the freetype font factory.
Looks to me like it loads the font correctly but then in PrismFontFactory.loadEmbeddedFont() at line 1584 it tests the FTFactory.registerEmbeddedFont(String path) method which always returns false and therefore it returns null instead of the loaded font.
Run the provided test class with Java 8u20 and the text will appear in the default font instead of a scripty looking font. If you run the test class in the released Java 8 it shows the custom font.
Also if I try to use the t2k font factory with 8u20 using the following system properties:
-Dprism.text=t2k
-Dprism.debugfonts=true
I get the following printed out:
Loading FontFactory com.sun.javafx.font.t2k.T2KFactory
Subpixel: enabled
Temp file created: /tmp/+JXF1067673701571616745.tmp
...
And it does load the custom font just as it did in previous Java 8 releases
***************************************** Test Class ************************************************
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Font;
import javafx.stage.Stage;
public class CustomFontTest extends Application {
@Override
public void start(final Stage primaryStage) throws Exception {
primaryStage.centerOnScreen();
primaryStage.setHeight(200);
primaryStage.setWidth(400);
Label label = new Label("The A Charming Font Font");
Font font = Font.loadFont(
"http://www.mediafont.com/storage/contents/4254/Achafont.ttf", 32);
if ( font != null ) {
label.setFont(font);
}
primaryStage.setScene(new Scene( new StackPane( label ) ));
primaryStage.show();
}
public static void main(String[] args) throws Exception {
launch(args);
}
}
Looks to me like it loads the font correctly but then in PrismFontFactory.loadEmbeddedFont() at line 1584 it tests the FTFactory.registerEmbeddedFont(String path) method which always returns false and therefore it returns null instead of the loaded font.
Run the provided test class with Java 8u20 and the text will appear in the default font instead of a scripty looking font. If you run the test class in the released Java 8 it shows the custom font.
Also if I try to use the t2k font factory with 8u20 using the following system properties:
-Dprism.text=t2k
-Dprism.debugfonts=true
I get the following printed out:
Loading FontFactory com.sun.javafx.font.t2k.T2KFactory
Subpixel: enabled
Temp file created: /tmp/+JXF1067673701571616745.tmp
...
And it does load the custom font just as it did in previous Java 8 releases
***************************************** Test Class ************************************************
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Font;
import javafx.stage.Stage;
public class CustomFontTest extends Application {
@Override
public void start(final Stage primaryStage) throws Exception {
primaryStage.centerOnScreen();
primaryStage.setHeight(200);
primaryStage.setWidth(400);
Label label = new Label("The A Charming Font Font");
Font font = Font.loadFont(
"http://www.mediafont.com/storage/contents/4254/Achafont.ttf", 32);
if ( font != null ) {
label.setFont(font);
}
primaryStage.setScene(new Scene( new StackPane( label ) ));
primaryStage.show();
}
public static void main(String[] args) throws Exception {
launch(args);
}
}
- duplicates
-
JDK-8094398 [Linux, Font] Native rasterizer on Linux unable to load woff fonts
- Closed
-
JDK-8094634 [Font] Native rasterizer ignores text.setFont(Font.loadFont("http://...")), rendering with default font instead
- Closed
-
JDK-8095952 [Linux] Font Awesome doesn't render properly
- Closed
- relates to
-
JDK-8094808 [Font, Linux] PangoGlyphLayout can't see embedded font
- Resolved