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

Incorrect glyph rendering on scaling Text node embedded in TextFlow

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • jfx21
    • javafx
    • None
    • generic
    • generic

      This issue came out during the code review https://github.com/openjdk/jfx/pull/1157 (JDK-8306083)

      When a Tex node embedded in TextFlow is scaled using -fx-scale-x, the glyph rendering gets affected and Text nodes gets overlapped as shown in the screenshots.

      CaretShape, preferredWidth, or hitInfo are not affected by changing the scale.

      Run the following program to reproduce the issue.

      ---------- BEGIN SOURCE ----------
      import javafx.application.Application;
      import javafx.scene.Node;
      import javafx.scene.Scene;
      import javafx.scene.layout.VBox;
      import javafx.scene.text.Font;
      import javafx.scene.text.Text;
      import javafx.scene.text.TextFlow;
      import javafx.stage.Stage;

      public class TextFlowSample extends Application {
          TextFlow control = new TextFlow();

          @Override
          public void start(Stage primaryStage) throws Exception {
              Node[] ts = createTextArray();
              control.getChildren().addAll(ts);

              VBox root = new VBox(control);
              Scene scene = new Scene(root, 400, 600);
              primaryStage.setScene(scene);
              primaryStage.show();
          }

          protected static Text t(String text, String style) {
              Text t = new Text(text);
              t.setStyle(style);
              t.setFont(new Font(48));
              return t;
          }

          protected Node[] createTextArray() {
              return new Node[] {
                      t("BOLD ", "-fx-font-weight:bold;"),
                      t("BOLD ", "-fx-font-weight:100; -fx-scale-x:200%;"),
                      t("BOLD ", "-fx-font-weight:bold;"),
              };
          }
          public static void main(String[] args) {
              launch();
          }
      }

      ---------- END SOURCE ----------

        1. glyph_issue_1.png
          15 kB
          Karthik P K
        2. glyph_issue_2.png
          19 kB
          Karthik P K

            Unassigned Unassigned
            kpk Karthik P K
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: