Unable to Load Glyph when packaged with onejar

Issue #16 open
Antoine Bergamaschi created an issue

Hi,

I use FontAwesomeFX library in my dependency and attempt to load the tff file contained in the jar but for some reason its not working with one jar packaging.

My work around was to load the tff file directly in my soft using an inputStream instead of a URL :

        try {
            Font.loadFont(FontAwesomeIconView.class.getResource("/de/jensd/fx/glyphs/fontawesome/fontawesome-webfont.ttf").openStream(),10.0D);
        } catch (IOException e) {
            e.printStackTrace();
        }

This code may be use instead of the :

  static {
        Font.loadFont(FontAwesomeIconView.class.getResource("/de/jensd/fx/glyphs/fontawesome/fontawesome-webfont.ttf").toExternalForm(), 10.0D);
    }

in the library.

I don't know why but it seems to always works instead of the URL version

Good luck

Antoine

Comments (2)

  1. Peter Rogge

    I see that in FontAwesomeFX 8.7

    static {
            try {
                Font.loadFont(GlyphsDude.class.getResource(FontAwesomeIconView.TTF_PATH).openStream(), 10.0);
                Font.loadFont(GlyphsDude.class.getResource(WeatherIconView.TTF_PATH).openStream(), 10.0);
                Font.loadFont(GlyphsDude.class.getResource(MaterialDesignIconView.TTF_PATH).openStream(), 10.0);
                Font.loadFont(GlyphsDude.class.getResource(MaterialIconView.TTF_PATH).openStream(), 10.0);
                Font.loadFont(GlyphsDude.class.getResource(OctIconView.TTF_PATH).openStream(), 10.0);
            } catch (IOException ex) {
                Logger.getLogger(MaterialDesignIconView.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    

    in GlyphsDude will be used.

    When I look at the JavaDoc from the method openStream() its tells me, that it will open an InputStream but don't closed it. So my question is where are the 5 InputStreams closed? Normally I would expected that after reading the font the InputStream will be closed. Means that that the InputStreams will be all open during the application lifetime?

  2. Log in to comment