You are not logged in.

#1 2019-08-18 05:21:41

dy5es41
Member
Registered: 2019-08-18
Posts: 4

Java font rendering

Hi all,
I have been attempting to run a javafx application via idea-community edition. My setup is a i3wm config. I am attempting to run a javafx application from the idea ide by intellj. From my  idea launcher I am able to build the application (code below). But am unable to run it. Here is my code and error respectively:

package sample;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class Main extends Application {

    @Override
    public void start(Stage primaryStage) throws Exception{
        Parent root = FXMLLoader.load(getClass().getResource("sample.fxml"));
        primaryStage.setTitle("Hello World");
        primaryStage.setScene(new Scene(root, 300, 275));
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }
}
/usr/lib/jvm/java-8-openjdk/bin/java -javaagent:/usr/share/idea/lib/idea_rt.jar=39031:/usr/share/idea/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-8-openjdk/jre/lib/charsets.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/cldrdata.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/jaccess.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/jfxrt.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/nashorn.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/sunec.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/sunjce_provider.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/jce.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/jfxswt.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/jsse.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/management-agent.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/resources.jar:/usr/lib/jvm/java-8-openjdk/jre/lib/rt.jar:/home/dy5es41/documents/ideaprojects/assignment2_1/out/production/assignment2_1 sample.Main
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=default
Error: JavaFX detected no fonts! Please refer to release notes for proper font configuration
Exception in Application start method
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
	at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
	at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$1(LauncherImpl.java:182)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ExceptionInInitializerError
	at javafx.scene.Node.reapplyCss(Node.java:8983)
	at javafx.scene.Node.impl_reapplyCSS(Node.java:8946)
	at javafx.scene.Node.invalidatedScenes(Node.java:854)
	at javafx.scene.Node.setScenes(Node.java:919)
	at javafx.scene.Scene$9.invalidated(Scene.java:1119)
	at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)
	at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
	at javafx.scene.Scene.setRoot(Scene.java:1072)
	at javafx.scene.Scene.<init>(Scene.java:347)
	at javafx.scene.Scene.<init>(Scene.java:223)
	at sample.Main.start(Main.java:15)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
	at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
	at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
	at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
	at com.sun.glass.ui.gtk.GtkApplication.lambda$null$10(GtkApplication.java:245)
	... 1 more
Caused by: java.lang.NullPointerException
	at com.sun.javafx.font.LogicalFont.<init>(LogicalFont.java:181)
	at com.sun.javafx.font.LogicalFont.getLogicalFont(LogicalFont.java:113)
	at com.sun.javafx.font.LogicalFont.getLogicalFont(LogicalFont.java:153)
	at com.sun.javafx.font.PrismFontFactory.createFont(PrismFontFactory.java:586)
	at com.sun.javafx.font.PrismFontLoader.loadFont(PrismFontLoader.java:206)
	at javafx.scene.text.Font.<init>(Font.java:319)
	at javafx.scene.text.Font.getDefault(Font.java:86)
	at javafx.scene.CssStyleHelper.<clinit>(CssStyleHelper.java:1528)
	... 20 more
Exception running application sample.Main

Process finished with exit code 1

Obviously my java installation is having trouble to find fonts (Error: JavaFX detected no fonts! Please refer to release notes for proper font configuration). For clarification I am using open-jdk8 with open-javafx installed. I have followed the following page to help configure my fonts, Java Runtime Environement. I appended the following to my /etc/environment file:

_JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=default'

In order for my JDK to pick up fonts. This setting gets picked up (see idea launcher error printout above). But sadly does not work as the same error persists. I have also attempted with other versions of java (open-jdk11, and the official oracle-8-jdk) but the same error persists across different jdk versions (I have been switching them in idea launcher. The console gives printout on what java version it runs so that I verified that the java version changed.

From there I have attemped to run the xsettingsd on startup to no effect.

Then I came across the following reddit post. A comment suggested a patch named  jre7-openjdk-headless-fontfix. Neither AUR package for jre7 or jre8 exists anymore and I can't seem to find it.

Going on from here I took another look at the Java Runtime Fonts page on the archlinux directory (link above). And installed the jre8-openjdk-infinality package. This had no effect on the error.

I have relogged after every attempt that I have taken here. What can I do to fix this?
Thanks smile

Offline

#2 2019-08-18 06:46:57

seth
Member
Registered: 2012-09-03
Posts: 51,686

Re: Java font rendering

What fonts do you have installed?

pacman -Qs 'ttf|otf'

Online

#3 2019-08-18 08:52:55

progandy
Member
Registered: 2012-05-17
Posts: 5,203

Re: Java font rendering

Do you get a font with fc-match if you ask for "System Regular"?
https://docs.oracle.com/javafx/2/api/ja … tDefault()

fc-match "System Regular"

| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#4 2019-08-18 10:45:47

dy5es41
Member
Registered: 2019-08-18
Posts: 4

Re: Java font rendering

seth wrote:

What fonts do you have installed?

pacman -Qs 'ttf|otf'

The output of that command is

[dy5es41@dy5es41 programs]$ pacman -Qs 'ttf|otf'
local/gnu-free-fonts 20120503-6
    A free family of scalable outline fonts

the directory /usr/share/fonts contains:

[dy5es41@dy5es41 etc]$ cd /usr/share/fonts/
[dy5es41@dy5es41 fonts]$ ls
adobe-source-code-pro  cantarell  gnu-free  gsfonts  mathjax
progandy wrote:

Do you get a font with fc-match if you ask for "System Regular"?
https://docs.oracle.com/javafx/2/api/ja … tDefault()

fc-match "System Regular"

The output of that command is

[dy5es41@dy5es41 fonts]$ fc-match "System Regular"
NimbusSans-Regular.otf: "Nimbus Sans" "Regular"

I have found the following AUR. It contains some jetbrains patches. I will install in and run it under my idea-ide. Will get back to you guys on the results.

Offline

#5 2019-08-18 11:01:01

dy5es41
Member
Registered: 2019-08-18
Posts: 4

Re: Java font rendering

Alright, installed the package above and attempted to run it with the jetbrains jdk. No difference. There is something wrong with my fonts  but I can't put my finger on it smile

Offline

#6 2019-08-19 09:20:31

dy5es41
Member
Registered: 2019-08-18
Posts: 4

Re: Java font rendering

Bump, I have worked myself into a corner and don't know how to fix this

Offline

#7 2019-08-19 09:33:05

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,790

Re: Java font rendering

The issue is with actual fonts, not font display, it won't matter which JDK you use for this your font configuration is broken, see https://wiki.archlinux.org/index.php/Ja … _selection if anything, but you more likely want to fix your general setup:

https://wiki.archlinux.org/index.php/Fo … Font_paths
https://wiki.archlinux.org/index.php/Fo … ault_fonts

You are likely to have some broken config somewhere. It's also somewhat weird that you seem to have quite a few system wide fonts without having their associated packages, how exactly did you install those?

Last edited by V1del (2019-08-19 09:38:34)

Offline

#8 2019-08-19 09:42:53

progandy
Member
Registered: 2012-05-17
Posts: 5,203

Re: Java font rendering

V1del wrote:

It's also somewhat weird that you seem to have quite a few system wide fonts without having their associated packages, how exactly did you install those?

I don't think that is relevant since gsfonts, adobe-source-code-pro-fonts, cantarell-fonts and mathjax do not have any references to ttf or otf in their package metadata, so the given pacman command is unable to display them. This should cover them, but include also some unrelated packages.

pacman -Qs 'ttf|otf|fonts'

Last edited by progandy (2019-08-19 09:45:49)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

Board footer

Powered by FluxBB