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

WebView displays an unselectable box after certain characters

XMLWordPrintable

    • web
    • x86_64
    • windows_10

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10
      Java build 24-ea+22-2649

      A DESCRIPTION OF THE PROBLEM :
      It was still normal in JavaFX 22-ea+28, but after that, characters with Unicode code points above 0xFFFF display an unselectable box after them in WebView, causing them to overlap with the following character. This issue still persists in the latest JavaFX 24-ea+15.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Source code for test:
      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.layout.VBox;
      import javafx.scene.web.WebEngine;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      import java.io.File;
      import java.nio.file.Files;

      public class WebViewDemo extends Application {
          @Override
          public void start(Stage primaryStage) throws Exception {
              VBox vBox = new VBox();
              WebView webView = new WebView();
              WebEngine webEngine = webView.getEngine();

              webEngine.setUserDataDirectory(new File(System.getProperty("java.io.tmpdir")));

              File htmlFle = File.createTempFile("testJfx", ".html");
              htmlFle.deleteOnExit();
              Files.writeString(htmlFle.toPath(), """
               <html>
                      <head>
                          <meta charset="UTF-8">
                          <style>
                              body {
                                  font-family: "Microsoft YaHei";
                                  font-size: 2rem;
                              }
                          </style>
                      </head>
                      <body>
                          <p>【韵会】𠀤莫六切,音目。</p>
                          <p>【说文】本作𤘴,养牛人也。从攴牛。</p>
                      </body>
                      </html>
                      """);
              System.out.println(htmlFle.toURI());
              webEngine.load(htmlFle.toURI().toString());

              vBox.getChildren().add(webView);
              Scene scene = new Scene(vBox, 800, 600);
              primaryStage.setTitle("JavaFX Version " + System.getProperty("javafx.runtime.version"));
              primaryStage.setScene(scene);
              primaryStage.show();
          }

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


        1. Test.java
          2 kB
        2. Okay.png
          Okay.png
          20 kB
        3. Error.png
          Error.png
          17 kB

            jbhaskar Jay Bhaskar
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: