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

[Font] New native font rasterizer in Linux fails to load non system true type fonts

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 8u20
    • 8u20
    • javafx
    • Java 8u20 b10 Linux

      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);
         }

      }

            fheidric Felipe Heidrich (Inactive)
            csmithjfx Charles Smith (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: