Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaFX Webview bad encoding

I try to open a webview in java and show the spotify login page. (https://accounts.spotify.com/en/login):

JFrame f = new JFrame();
    f.setTitle("Spotify");
    f.setSize(500,500);
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JFXPanel jfxPanel = new JFXPanel();
    f.add(jfxPanel);
    Platform.runLater(() -> {
        WebView webView = new WebView();
        jfxPanel.setScene(new Scene(webView));
        WebEngine webEngine = webView.getEngine();
        webEngine.load("https://accounts.spotify.com/en/login");
    });

The result is the window below. (when i copy the cryptic text and paste it in another application, it shows me the text with right encoding.
How can I display the spotify login page with correct encoding?

http://fs2.directupload.net/images/150909/zyk25eqz.png

like image 505
Felix Avatar asked Oct 31 '22 19:10

Felix


1 Answers

I saw this at the dropbox login page in my WebView, too.

The problem you encountered has nothing to do with encoding. The JavaFx WebView has some problems with loading local fonts. If you load a website which wants to load a local font installed on your computer you will see this cryptic letters. If you remove the font you will see the text as usual.

So your problem isn't the encoding of the website, it's the font spotify want's to load and you are having local on your pc.

You will have to find a way to stop the WebView from loading local fonts. Maybe by injecting some code.

like image 185
Nicole Avatar answered Nov 02 '22 09:11

Nicole