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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With