Question

Is it possible to use a font not on the user's machine for text displayed in a java applet. Like linking to a ttf font file in the same location as the java applet almost in an @fontface fashion.

Was it helpful?

Solution

You can use Font.createFont with fontFormat TRUETYPE_FONT:

Font f = Font.createFont( Font.TRUETYPE_FONT, new FileInputStream("font.ttf") );

As also described in Sun-Tutorial Working with Text APIs the returned font size is 1 pt, you can change this afterwards:

f = font.deriveFont(12f);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top