Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
friedev opened this issue Feb 13, 2022 · 0 comments
Open

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

friedev opened this issue Feb 13, 2022 · 0 comments

Comments

@friedev
Copy link

friedev commented Feb 13, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant