import java.io.*;
import java.awt.*;
import java.awt.event.*;
public class IncludedFont extends Panel {
public IncludedFont() {}
public void paint(Graphics g) {
try {
Graphics2D g2 = (Graphics2D) g.create();
Font font = Font.createFont( Font.TRUETYPE_FONT, getClass().getClassLoader().getResource("Gondrini.ttf").openStream() ).deriveFont( 40f );
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setFont(font);
g2.drawString("An included font", 50, 150);
} catch (FileNotFoundException e) {
System.out.println(e);
} catch (FontFormatException e) {
System.out.println(e);
} catch (IOException e) {
System.out.println(e);
}
}
public static void main(String[] args) {
Frame f = new Frame("Font example");
IncludedFont p = new IncludedFont();
f.add(p);
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
f.setSize(500,400);
f.setVisible(true);
}
}