在Eclipse中导出字体到jar [英] Exporting font to jar in eclipse
本文介绍了在Eclipse中导出字体到jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试导出一个字体,以便您不必安装字体来运行游戏
它在eclipse中工作,但导出它不起作用
I'm trying to export a font so that you don't have to install the font to run the game it's working in eclipse but exporting it doesn't work
文件夹结构如下:
Project_name
/src
-Core(package)
-game(package)
/Fonts
-Origin-Light.ttf
我使用以下命令加载字体:
I load the font in with following command:
font = Font.createFont(Font.TRUETYPE_FONT,
new FileInputStream("./Fonts/Origin-Light.ttf"));
它的工作正常,但导出似乎不会加载到字体
in eclipse it's working just fine, but exporting doesn't seem to load in the font
编辑:
jar文件中的结构:
edit: Structure in jar file:
/core
- main.class
- ....
/Fonts
- Origin-Light.ttf
/game
- otherclasses.class
/META-INF
- MANIFEST.MF
/org
/eclipse
some more folders
推荐答案
将fonts文件夹放在源文件夹中,我相信这是一个问题:
Put the fonts folder inside of your source folder, I believe that's the issue:
Project_name
/src
/Fonts
-Origin-Light.ttf
-Core(package)
-game(package)
解决了聊天,最终代码:
Resolved in chat, final code:
try {
font = Font.createFont(Font.TRUETYPE_FONT,
trial.class.getClassLoader().getResourceAsStream("Fonts/Origin-Light.ttf"));
} catch (Exception e) {
e.printStackTrace();
}
这篇关于在Eclipse中导出字体到jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文