I have a custom font I want to show off in a Java program where the user can view it without having to install it. Does anyone know how to do that?
I have never done it, but it seems like the methods you want are
Importing the Font
Font createFont(int fontFormat, InputStream fontStream)
or alternatively
Font createFont(int fontFormat, File fontFile)
The int
parameter is either Font.TRUETYPE_FONT or Font.TYPE1_FONT, while the InputStream
or File
parameter contains the font's binary data.
Using the Font after import:
To make the Font available to Font constructors the returned Font must be registered in the
GraphicsEnviroment
by calling registerFont(Font).