import Font - Java 2D Graphics

Java examples for 2D Graphics:Font

Description

import Font

Demo Code


//package com.java2s;

import java.awt.Font;
import java.awt.FontFormatException;

import java.awt.GraphicsEnvironment;

import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static void importFont(InputStream stream) {
        try {//from  w w w .j  av a  2s  . co  m
            Font font1 = Font.createFont(Font.TRUETYPE_FONT, stream);
            GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(
                    font1);
        } catch (FontFormatException ex) {
            throw new RuntimeException(ex);
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
}

Related Tutorials