Java Font.createFont(int fontFormat, InputStream fontStream)
Syntax
Font.createFont(int fontFormat, InputStream fontStream) has the following syntax.
public static Font createFont(int fontFormat, InputStream fontStream) throws FontFormatException , IOException
Example
In the following code shows how to use Font.createFont(int fontFormat, InputStream fontStream) method.
//from w ww .j av a 2 s. co m
import java.awt.Font;
import java.io.FileInputStream;
import java.io.InputStream;
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(Font.PLAIN, 24);
}
}
Home »
Java Tutorial »
java.awt »
Java Tutorial »
java.awt »