2

I have a kiosk program which writes some text on the screen. It is working fine on my Ubuntu 18 laptop and on a Raspberry Pi 3b running Raspbian. For minimal overhead, I'm using Arch Linux on a Raspberry Pi 3b running only X.org (+ xterm) to launch my program. But it fails without any usable information:

java.io.IOException: Problem reading font data.
at java.desktop/java.awt.Font.createFont0(Font.java:1177)
at java.desktop/java.awt.Font.createFont(Font.java:1046)
at code.Frame.(Frame.java:146)
at code.Main.main(Main.java:58)

The machine is running jre-openjdk 13 and the font is loaded from the JAR.

I have already tried to change java.io.tmpdir, to a definitely writable directory. I've also lowercased all files.

The basic structure is:

  • code
    • Main
    • Frame
  • resources
    • roboto_bold.ttf

And this is my code:

Font.createFont(Font.TRUETYPE_FONT, Main.class.getResourceAsStream("/resources/roboto_bold.ttf"))

Any idea what the issue is or how I can debug this?

UPDATE:

I have started debugging the call remotely using IntelliJ. This way I was able to create a stacktrace:

java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at java.desktop/sun.font.FontManagerFactory$1.run(FontManagerFactory.java:84)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:312)
at java.desktop/sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
at java.desktop/java.awt.Font.createFont0(Font.java:1139)
at java.desktop/java.awt.Font.createFont(Font.java:1046)
at code.Frame.(Frame.java:146)
at code.Main.main(Main.java:58)

I think this means sun.awt.X11FontManager isn't present. I do not know how to fix that though. Seems like a dependency issue, but extra/fontconfig 2:2.13.91 and extra/freetype2 2.10.1 are installed.

Minding
  • 1,383
  • 1
  • 17
  • 29

1 Answers1

0

You'd need a structure like:

src:
   com.company
     Main.java
   resources
     roboto_bold.ttf
MadaManu
  • 868
  • 4
  • 10
  • The given structure is in the `src` directory (could've made that clearer). It is working in Ubuntu 18. So it seems to be some platform-dependend issue. – Minding Jan 02 '20 at 02:37
  • Ups, I missed that part of the question. Is the Ubuntu using the same JRE? The fact that it's a java application, should abstract the platform issues away (hopefully) – MadaManu Jan 02 '20 at 02:41
  • The laptop is using Java 11. Yeah, Java does add a lot of portability, but it does have gaps. I saw someone have this issue because the paths on Windows aren't casesenitive, but are on Linux. – Minding Jan 02 '20 at 02:47
  • Can you match java 11 on the pi too? – MadaManu Jan 02 '20 at 03:11