Issue loading custom font

后端 未结 3 1954
天涯浪人
天涯浪人 2021-01-23 02:16

I am attempting to load a font, in slick2d, which (in eclipse) is located at: \"resources\\fonts\\slkscr.ttf\" with the following code:

private void         


        
3条回答
  •  臣服心动
    2021-01-23 02:43

    Put a leading slash to indicate to search from the root of the class-path, vis.

    ..getResourceAsStream("/resources/fonts/slkscr.ttf")..
    

    As an aside. That stream closed message might be telling us that createFont requires a repositionable InputStream. Try instead:

    getResource("/resources/fonts/slkscr.ttf")
    

    ..or..

    getResource("/slkscr.ttf")
    

    ..depending upon path.

提交回复
热议问题