Intellj Idea JavaFx wrong Encoding

Answered

I made a JavaFx application using SceneBuilder and now when i run the app the text is the wrong font, in the code the labels are correct.

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="387.0" prefWidth="489.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8" fx:controller="sample.Controller">
<children>
<Label fx:id="label" layoutX="126" layoutY="120" minHeight="16" minWidth="69" />
<Label layoutX="281.0" layoutY="55.0" text="Port" />
<TextField layoutX="100.0" layoutY="49.0" />
<Label layoutX="25.0" layoutY="87.0" text="Datenbank" />
<TextField layoutX="100.0" layoutY="83.0" />
<Label layoutX="24.0" layoutY="120.0" prefHeight="17.0" prefWidth="69.0" text="Username" />
<TextField layoutX="100.0" layoutY="116.0" />
<Label layoutX="24.0" layoutY="149.0" prefHeight="17.0" prefWidth="69.0" text="Passwort" />
<Label layoutX="26.0" layoutY="53.0" text="Hostname" />
<TextField layoutX="311.0" layoutY="51.0" prefHeight="25.0" prefWidth="69.0" />
<Button layoutX="328.0" layoutY="154.0" mnemonicParsing="false" text="Get Data" />
<Separator layoutY="188.0" prefHeight="9.0" prefWidth="489.0" />
<TableView layoutX="17.0" layoutY="197.0" prefHeight="168.0" prefWidth="456.0">
<columns>
<TableColumn prefWidth="75.0" text="Gemeinde" />
<TableColumn prefWidth="133.0" text="Verwaltungseinheit" />
<TableColumn prefWidth="75.0" text="Hauptstadt" />
<TableColumn prefWidth="75.0" text="Einwohner" />
<TableColumn prefWidth="97.0" text="Webseite" />
</columns>
</TableView>
<PasswordField layoutX="100.0" layoutY="145.0" />
<MenuBar layoutY="-1.0" prefHeight="31.0" prefWidth="500.0">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" text="Close" />
</items>
</Menu>
</menus>
</MenuBar>
</children>
</AnchorPane>

4 comments
Comment actions Permalink

Hello,

Please try using the escaped Unicode sequences to see if it helps. See the related discussion at https://stackoverflow.com/a/57807845/12844632 .

See also https://www.jetbrains.com/help/idea/encoding.html .

1
Comment actions Permalink

I tried it, did not work.

0
Comment actions Permalink

The problem is not reproduced for my work environment. What file encoding do you see in the bottom right corner of the editor? Does it help if you add -Dfile.encoding=UTF-8 in Help | Edit Custom VM Options and restart IntelliJ IDEA?

0
Comment actions Permalink

you can fix by adding -fx-font-family to your .root, e.g.

.root {
-fx-font-family: "Arial";
}

not sure what is different about my new env that i can't load the font, but that in the console about font loading and a search in stackoverflow with that error message got me this fix

java[3129:69795] CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].

https://stackoverflow.com/questions/66891857/when-running-the-program-in-netbeans-the-font-looks-extremely-weird/70492836#comment127456132_70492836

0

Please sign in to leave a comment.