embedding a font in Java

后端 未结 1 549
时光取名叫无心
时光取名叫无心 2020-12-09 11:39

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

相关标签:
1条回答
  • 2020-12-09 12:31

    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).

    0 讨论(0)
提交回复
热议问题