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

Bug in PrismFontFactory generates NullPointerException when loading .ttc font

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u60
    • Fix Version/s: 9
    • Component/s: javafx
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      os_x

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_60"
      Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
      Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      in method createFontResource line 333:

      > if (index == 0 || name.equals(fontname))

      name is the parameter to the method.index can be != 0 when loading .ttc file so the check for equality is performed.

      createFontResource is called from loadEmbeddedFont which is called from e.g. PrismFontLoader.loadFont with null name parameter.



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Toolkit.getToolkit().getFontLoader().loadFont("PTSans.ttc", 16);
      returns null. The following css fragment prints exception to the console:

      @font-face {
       src: url("PTSans.ttc");

      }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Font does not load.

      ACTUAL -
      Font should load


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Caused by: java.lang.NullPointerException
      at com.sun.javafx.font.PrismFontFactory.createFontResource(PrismFontFactory.java:333)
      at com.sun.javafx.font.PrismFontFactory.loadEmbeddedFont(PrismFontFactory.java:1607)
      at com.sun.javafx.font.PrismFontFactory.loadEmbeddedFont(PrismFontFactory.java:1547)
      at com.sun.javafx.font.PrismFontLoader.loadFont(PrismFontLoader.java:99)
      at javafx.scene.text.Font.loadFont(Font.java:400)
      at com.sun.javafx.css.StyleManager.loadStylesheetUnPrivileged(StyleManager.java:1109)
      at com.sun.javafx.css.StyleManager.loadStylesheet(StyleManager.java:917)
      at com.sun.javafx.css.StyleManager.processStylesheets(StyleManager.java:1538)
      at com.sun.javafx.css.StyleManager.gatherParentStylesheets(StyleManager.java:1579)
      at com.sun.javafx.css.StyleManager.findMatchingStyles(StyleManager.java:1641)
      at javafx.scene.CssStyleHelper.createStyleHelper(CssStyleHelper.java:111)
      at javafx.scene.Node.reapplyCss(Node.java:8983)
      at javafx.scene.Node.impl_reapplyCSS(Node.java:8946)
      at javafx.scene.Node.invalidatedScenes(Node.java:854)
      at javafx.scene.Node.setScenes(Node.java:919)
      at javafx.scene.Parent.scenesChanged(Parent.java:659)
      at javafx.scene.Node.invalidatedScenes(Node.java:853)
      at javafx.scene.Node.setScenes(Node.java:919)
      at javafx.scene.Scene$9.invalidated(Scene.java:1119)
      at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)
      at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
      at javafx.scene.Scene.setRoot(Scene.java:1072)
      at javafx.scene.Scene.<init>(Scene.java:347)
      at javafx.scene.Scene.<init>(Scene.java:223)
      at sample.Main.start(Main.java:18)
      at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$163(LauncherImpl.java:863)
      at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(PlatformImpl.java:326)
      at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
      at java.security.AccessController.doPrivileged(Native Method)
      at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
      at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)

      REPRODUCIBILITY :
      This bug can be reproduced always.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                prr Philip Race
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: