Hi all,
I want to load a Font from a .tff file, so I can draw text on a GreenfootImage with another font.
I tried some things, but I can't seem to get it working.
Can anybody help? Thanks.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | Font font = new Font( "q" , 0 , 0 ); InputStream is = Glo. class .getResourceAsStream( "resources/Vdj.ttf" ); //location in project folder Font uniFont = null ; try { uniFont=Font.createFont(Font.TRUETYPE_FONT,is); } catch (java.awt.FontFormatException r){ System.err.println( "FontFormatException: " + r.getMessage()); } catch (java.io.IOException r){ System.err.println( "FontFormatException: " + r.getMessage()); } font = uniFont.deriveFont(24f); //desired font size |
1 | URL url = new URL(getCodeBase(), "resources/Vdj.ttf" ); |