• Post Reply Bookmark Topic Watch Topic
  • New Topic

New Fonts in Java Runtime  RSS feed

 
sreedhar vanam
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As we know currently ,the Java Runtime supports only Serif,Sans-serif,Monospaced,Dialog,DialogInput Fonts only.So,i want to use all MS windows fonts to my Java application.
So,please let me know .....how to customise my application(or JRE) for other fonts?.
Thanks,
Sreedhar
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK... for windows, you would copy the font file to the windows font directory... I am not sure how to install fonts on other systems, but the first step to make this work is to actually install a font to your system.

Anyway, once you have the font installed, you need to find out what the font is actually named, according to Java... this is usually pretty obvious, but here is a program that prints out all the fonts on your system and gives their names.




Once you have the font loaded, you simply create an instance of it using the Font constructor that takes a String representing this name, an integer representing a style ( Font.PLAIN, Font.BOLD, etc. ), and an integer value for the size.

As far as installing the font with your class... that is a little harder... under windows, you could just have a zip file that extracts the font file to the fonts directory inside the windows directory...

JAR files may have some special way to have the font file inside the JAR file and use it as a resource... I am not sure on this point, and I will have to research it more... but it would certainly be useful to do, if it is possible...

-Nate
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!