|
Hi,
as the destination machines I should run my program on, dont have the font I want to use, I load the font from my "fonts" folder instead of using windows installed fonts, but it does not work
If I load it from windows installed fonts, it works
loadUninstalledFont seems to work and return a good font object, but nothing is printed on the screen
//load
bigFont = new TextRenderer(Tools.loadUninstalledFont("fonts/SFDistantGalaxy.ttf"));
// this works but requires font to be installed in windows
// bigFont = new TextRenderer(new Font("SF Distant Galaxy", Font.PLAIN, 12));
public static Font loadUninstalledFont(String fileName)
{
InputStream fontStream;
try {
fontStream = new FileInputStream(fileName);
return Font.createFont( Font.TRUETYPE_FONT, fontStream );
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (FontFormatException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
return null;
}
// draw text
bigFont.beginRendering(getWidth(), getHeight());
tinyFont.setColor(1.0f, 1.0f, 1.0f, 1.0f);
bigFont.draw("test", 100, 100);
bigFont.flush();
bigFont.endRendering();
thanks
|