Java Font.deriveFont(float size)
Syntax
Font.deriveFont(float size) has the following syntax.
public Font deriveFont(float size)
Example
In the following code shows how to use Font.deriveFont(float size) method.
import java.awt.Font;
import java.io.FileInputStream;
import java.io.InputStream;
/*from w w w. j a v a 2 s. c om*/
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(24F);
}
}
Home »
Java Tutorial »
java.awt »
Java Tutorial »
java.awt »