Font: deriveFont(int style, float size)
import java.awt.Font;
import java.awt.FontFormatException;
import java.io.IOException;
import java.io.InputStream;
import javax.swing.JPanel;
public class MainClass extends JPanel {
public void loadFont() throws FontFormatException, IOException{
String fontFileName = "yourfont.ttf";
InputStream is = this.getClass().getResourceAsStream(fontFileName);
Font ttfBase = Font.createFont(Font.TRUETYPE_FONT, is);
Font ttfReal = ttfBase.deriveFont(Font.PLAIN, 24);
}
public static void main(String[] args) {
}
}
Related examples in the same category