Skip to content

Font files can only be loaded from the Java classpath #20

@friedev

Description

@friedev

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions