Ugly fonts in Netbeans - How can i make it use the system font?

As has been stated in the comments, this is a problem with Java Swing apps on Linux. Swing does use Gnome's font smoothing settings (deactivated, greyscale or subpixel) - it disregards the hinting settings though. It always uses full hinting, and if you're running Ubuntu with little or no font hinting (as most people do since little hinting is the default setting) this will make the font appear significantly different than in other applications. SWT applications like Eclipse are fine, but if you like Netbeans this isn't gonna help you.

Caveat: For the following workaround I'm only talking about the editor font, because in an IDE that's what's important to me. You could also apply it to the menu fonts etc, but that might be a little over the top.

The only usable solution I found here : use Fontforge to edit your editor font of choice and remove all hinting information from the font itself, then save it as a new font and use that in Netbeans.

  1. sudo apt-get install fontforge
  2. Launch Fontforge
  3. Open your font of choice
  4. Ctrl+A or edit -> Select -> Select all to select all characters
  5. Hints ⇒ Clear instructions
  6. Ctrl+Shift+F or element -> font info to open the font info
  7. Rename font (e.g. to original name + '_nohints')
  8. Save edited font in the .fonts directory in your home, through file -> generate fonts, making sure to use a format that Ubuntu reads (see next step)
  9. Clear font cache fc-cache -rv - following its output to make sure your new font file was picked up (e.g. .sfd doesn't but .ttf does).
  10. Run Netbeans and use the font you created as editor font

No, not perfect and yes, a bit of a hassle, but still a world of difference. Hope that helps.


Add

--laf Nimbus -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd

or

-J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd --laf Metal

to the file : netbeans.config. You can find it in $NETBEANS_HOME/etc/ folder. Make your application font smaller from system preferences.

Source


I know this is an old question, but in my quest for the same problem, I tried all the tricks here without luck. I thought I was just going to have to live with terrible text in netbeans.

Then I found this: http://youtrack.jetbrains.com/issue/IDEA-57233#comment=27-472038

Basically: Ubuntu 13.10, Netbeans (7.3), Infinality font patches to freetype, OpenJDK7, and patches to it to fix Swings dismal font handling. And it "just worked"!!!

Copied here in case that link dies:

  1. install freetype

    $ sudo apt-get install libfreetype6
    
  2. install infinality patch

    $ sudo add-apt-repository ppa:no1wantdthisname/ppa
    $ sudo apt-get update
    $ sudo apt-get install fontconfig-infinality
    

    I had to do the following afterwards:

    $ sudo rm /etc/fonts/conf.avail/52-infinality.conf
    $ sudo ln -s /etc/fonts/infinality/infinality.conf /etc/fonts/conf.avail/52-infinality.conf
    

    To use Windows 7 like font rendering do the following:

    $ sudo /etc/fonts/infinality/infctl.sh setstyle win7
    

    Set USE_STYLE to "WINDOWS7" in /etc/profile.d/infinality-settings.sh

  3. install font fixed OpenJDK

    $ sudo add-apt-repository ppa:no1wantdthisname/openjdk-fontfix
    $ sudo apt-get update
    $ sudo apt-get install openjdk-7-jdk
    

    In .../etc/netbeans.conf,

    netbeans_default_options includes: -J-Dawt.useSystemAAFontSettings=lcd and -J-Dsun.java2d.xrender=true"

    and set netbeans_jdkhome="/usr/lib/jvm/java-1.7.0-openjdk-amd64"

This changed my Netbeans fonts from 1990's acceptable to modern day awesome. And I can now use the Inconsolata as my Netbeans editor font and it looks GREAT.

Screen shot as requested: (actual text is clearer than this capture. something in the capture blurred it slightly). enter image description here

Tags:

Fonts

Netbeans