Font: deriveFont(int style, float size) : Font « java.awt « Java by API






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

1.Font.PLAIN
2.Font.BOLD | Font.ITALIC
3.Font.BOLD
4.Font.ITALIC
5.Font.TRUETYPE_FONT
6.new Font(String name, int style, int size)
7.Font: createFont(int fontFormat, InputStream fontStream)
8.Font: createGlyphVector(FontRenderContext frc, String str)
9.Font: getFamily()
10.Font: getFontName()
11.Font: getLineMetrics(String str, FontRenderContext frc)
12.Font: getName()
13.Font: getStyle()
14.Font: getSize()
15.Font: getStringBounds(String str, FontRenderContext frc)