How to configure JRE to run on specific font

11,338

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
    
Share:
11,338
Min Naing Oo
Author by

Min Naing Oo

Updated on June 05, 2022

Comments

  • Min Naing Oo
    Min Naing Oo almost 2 years

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

  • Min Naing Oo
    Min Naing Oo about 10 years
    Thank you for the answer. I search their forum and found out that pos is customized with look and feel. Does look and feel override the changes in code? I changed setFont method in java code but it did't take effect. Where am I start looking to change look and feel of that program?
  • DonyorM
    DonyorM about 10 years
    I believe the look and feel sets the default, well, look and feel. For whatever reason, your code is having trouble changing the default.