Question

I've downloaded the java open source gui POS software and would like to change it to be able to display non-unicode font which include our local language.

I know that I can change the font of the gui components by component.setFont(new java.awt.Font("MyFont", 1, 14)) but there are a lot of components to change in order to make it display. Instead, I think changing the JRE default font will be a lot easy than changing the code.

According to Java Document, I've tried like the following so far - but it's not working.

Changed fontconfig.properties.src to fontconfig.properties under jre/lib/

In fontconfig.properties

Changed the font names to the one I want like this.

serif.plain.alphabetic=Times New Roman (=> serif.plain.alphabetic=MyFont)
sansserif.plain.alphabetic=Arial (=> serif.plain.alphabetic=MyFont)
monospaced.plain.alphabetic=Courier New (=> serif.plain.alphabetic=MyFont)
dialog.plain.alphabetic=Arial (=> serif.plain.alphabetic=MyFont)
dialoginput.plain.alphabetic=Courier New (=> serif.plain.alphabetic=MyFont)

and finally added this line.

filename.MyFont=MyFont.ttf

System Info:

Windows 7, jdk1.7.0

What am I doing wrong? Any advice would be very appreciated. Thank you :)

Was it helpful?

Solution

Also looking for a way to change the jre's default font, editing fontconfig.properties worked for me actually (oracle java 6, linux in my case):

  • edit jre/lib/fontconfig.Ubuntu.properties

  • To change the default font replace all DejaVu Sans with Ubuntu for example, and add the path to the font files:

    # Font File Names
    
    filename.Ubuntu=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-R.ttf
    filename.Ubuntu_Bold=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-B.ttf
    filename.Ubuntu_Oblique=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-RI.ttf
    filename.Ubuntu_Bold_Oblique=/usr/share/fonts/truetype/ubuntu-font-family/Ubuntu-BI.ttf
    
    filename.Ubuntu_Mono=/usr/share/fonts/truetype/ubuntu-font-family/UbuntuMono-R.ttf
    filename.Ubuntu_Mono_Bold=/usr/share/fonts/truetype/ubuntu-font-family/UbuntuMono-B.ttf
    filename.Ubuntu_Mono_Oblique=/usr/share/fonts/truetype/ubuntu-font-family/UbuntuMono-RI.ttf
    filename.Ubuntu_Mono_Bold_Oblique=/usr/share/fonts/truetype/ubuntu-font-family/UbuntuMono-BI.ttf
    

OTHER TIPS

I would suggest creating a custom look and feel. This will allow you to change the font and many other things. You can base it off Nimbus, or Syth. Here is the main look and feel java doc. Look here for some examples on modifying the look and feel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top