trystan/AsciiPanel

Font files can only be loaded from the Java classpath

Opened this issue · 0 comments

loadGlyphs() uses the Java class loader to load image resources:

glyphSprite = ImageIO.read(AsciiPanel.class.getClassLoader().getResource(terminalFontFile));

This means that any font file you want to load must be on the Java classpath. It would be nice to be able to load font images from any arbitrary file path instead.


As a workaround, you can add a directory containing your images to the classpath, and use a relative path when creating your AsciiFont. The way I ended up implementing this workaround in Gradle is as follows:

jar {
    manifest {
        attributes('Class-Path': '..')
    }
}

(I used .. rather than . because my JAR was in a lib directory, and my paths were relative to the containing directory, but this should work in other situations too.)