Java Swing Tutorial - Java Font .deriveFont (AffineTransform trans)








Syntax

Font.deriveFont(AffineTransform trans) has the following syntax.

public Font deriveFont(AffineTransform trans)

Example

In the following code shows how to use Font.deriveFont(AffineTransform trans) method.

import java.awt.Font;
import java.awt.geom.AffineTransform;
import java.io.FileInputStream;
import java.io.InputStream;
/*  ww w .j  a  v a 2 s  .  co  m*/
public class Main {
  public static void main(String[] args) throws Exception{
    String fontFileName = "yourfont.ttf";
    InputStream is = new FileInputStream(fontFileName);

    Font ttfBase = Font.createFont(Font.TRUETYPE_FONT, is);

    Font ttfReal = ttfBase.deriveFont(AffineTransform.getRotateInstance(0.5));
  }

}