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?
working solution
I have implemented the following:
font = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, new java.io.File(Clazz.class.getResource("/resources/segoescb.ttf").toURI()));
font = font.deriveFont(11.0F);
解决方案
I have never done it, but it seems like the methods you want are
Importing the Font
or alternatively
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).