Skip to main content

Using ttf font runtime in an applet

2 replies [Last post]
Joined: 2009-02-26

I have a certain font I want to use with an applet that is not part of standard windows (is a ttf file)

Is it possible to use the font runtime in an applet without installing the font ttf file? Would be great if I could put the ttf file into a resource jar and use it within my swing components in my applet.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-07-24

The Java specification is your friend. Read:

and pay attention to the createFont() static methods.

Joined: 2009-02-26

Thanks, createfont does the trick, though you need to use derivefont aswell which isn't clear in the specification but found the info in a demo.

Font font = Font.createFont(Font.TRUETYPE_FONT, Resource.getResourceAsStream("test.ttf"));
} catch(Exception e){

font = font.deriveFont(Font.PLAIN,16f);