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

Custom font's weight or style ignored

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      other

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_111"
      Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.14393]

      A DESCRIPTION OF THE PROBLEM :
      When I try to load a custom font and display it with some styles or weights, the font gets successfully displayed but the styles or weights are ignored

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      final Group rootGroup = new Group();
              final Scene scene = new Scene(rootGroup, 300, 200, Color.WHITE);

              Font font = Font.loadFont(getClass().getResourceAsStream("font2.otf"), 25);
              System.out.println(font);

              final Text text1 = new Text(25, 25, "Italic");
              text1.setFont(font);
              text1.setStyle("-fx-font-style: italic;");
              rootGroup.getChildren().add(text1);

              final Text text2 = new Text(25, 100, "Bold");
              text2.setFont(font);
              text2.setStyle("-fx-font-weight: bold;");
              rootGroup.getChildren().add(text2);


              stage.setScene(scene);
              stage.show();

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      "Italic" in the custom font with the italic's style and "Bold" in the custom font with the bold's weight
      ACTUAL -
      The two texts written in the custom font but without any weight or style

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.paint.Color;
      import javafx.scene.text.Font;
      import javafx.scene.text.Text;
      import javafx.stage.Stage;

      public class Main extends Application{


          public static void main(String... args) {
              launch(args);
          }

          @Override
          public void start(Stage stage) throws Exception {
              final Group rootGroup = new Group();
              final Scene scene = new Scene(rootGroup, 300, 200, Color.WHITE);

              Font font = Font.loadFont(getClass().getResourceAsStream("font2.otf"), 25);
              System.out.println(font);

              final Text text1 = new Text(25, 25, "Italic");
              text1.setFont(font);
              text1.setStyle("-fx-font-style: italic;");
              rootGroup.getChildren().add(text1);

              final Text text2 = new Text(25, 100, "Bold");
              text2.setFont(font);
              text2.setStyle("-fx-font-weight: bold;");
              rootGroup.getChildren().add(text2);


              stage.setScene(scene);
              stage.show();
          }
      }
      ---------- END SOURCE ----------

        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

                • Created:
                  Updated: