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

    Details

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

      Java 8u20 b10 Linux

      Description

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

      }

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                Created:
                Updated:
                Resolved:
                Imported: