Installing fonts from the java program

I would like to install a font set into a Windows system from my java class. I use this font for my Birt report.

+4
source share
3 answers

You can write the / powershell script package and include it along with the font files in your application. Then you can execute the script with

Runtime.getRuntime().exec(...) 

Most likely, you will need to increase privileges for your application after its launch.

As for the password transfer. You can run cmd.exe so that it pops up and prompts the user. You can also try assigning the return value of exec to an object of the Process class that has the InputStream and OutputStream . I am not sure how to do this. I did this once in a project, a couple of years ago, but I no longer have code.

If you only need to install fonts once, consider creating an installer for your Java application that takes care of this. There is a neat installation generator called IzPack, which allows you to create complex installers using XML. It also allows you to elevate privileges for executable files that are executed during installation. So I do such things.

+2
source

You can install these fonts by the user System โ†’ Fonts if you are in a window to check it. If you are trying to organize it using your program, you should start by including them in your java resource file in order to access it later.

Hope this helps ~

0
source

Without local administrator rights, you can add custom fonts to the font cache. Then your custom fonts will be available for all of your applications until you log out. Windows API that does this is AddFontResource . With the JNI helper DLL, you can call it directly or simply execute the RegisterFonts utility.

0
source

Source: https://habr.com/ru/post/1414853/


All Articles