70

I'm having problems getting the Netbeans font to look nice, this has been a problem ever since I tried Ubuntu ~8. For some reason fonts look like they're not getting subpixel smoothing in Netbeans only, for the rest of the applications they look perfect.

Look at how ugly the screenshot is:

enter image description here

It's not just the code area but every font in the application looks this way. I was looking around and apparently adding the following line to the .bashrc file should fix the issue but in my case it didn't:

export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=lcd'

It think it might only affect Java based applications, but I haven't been able to test another Java app to check the fonts out.

Does anyone know what can I do to fix this? How can I make Netbeans use the system font?

8
  • I've also looked and looked for a fix for this, but there just doesn't seem to be one. Specifically it affects Swing-based applications; you'll find that Eclipse, for example, looks fine. I'm actually not too bothered about the code font (it's changeable, and I find that it looks OK with Droid Sans Mono at 11pt) but the chrome fonts really irk me. Mar 30, 2011 at 18:00
  • Yes it seems to affect only java based apps, I'm thinking about changing my IDE just because of this.. Apr 5, 2011 at 15:03
  • Actually, I specifically mentioned Swing because the font problem is not visible in SWT applications, such as Eclipse. Either way, though, it only affects (some) Java applications. Also, I can confirm that the problem is still there in Netbeans 7.0 RC1. Apr 6, 2011 at 20:07
  • You're right I switched to Aptana and they look fine there, hope I can find fix for this I really like Netbeans but those font were driving me crazy. Apr 8, 2011 at 3:55
  • 1
    I'm using now 'Droid Sans Mono', size 16 with '-J-Dawt.useSystemAAFontSettings=on --laf javax.swing.plaf.nimbus.NimbusLookAndFeel -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true'
    – Karussell
    Aug 28, 2014 at 13:08

17 Answers 17

39

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.

3
  • 3
    I used Monospace, the default one in NetBeans. I tried to fix Ubuntu Monospace, and it looks better now, but still worse then Monospace. Thanks anyway. If I could find Monospace location on file system, I would try to fix it too.
    – umpirsky
    Dec 19, 2012 at 23:16
  • Thank you so much... The only working solution I've found. I was going crazy with this !! Aug 13, 2013 at 9:13
  • Not sure which font file is my font... Got 9 different font files for the Ubuntu font alone, so needed to consult font.ubuntu.com to figure which one to tinker. Hope this will work.
    – matanox
    Nov 7, 2015 at 9:54
18

Add

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

or

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

at the end of the default_options string in the file netbeans.config. You can find it in $NETBEANS_PATH/etc/ folder. Make your application font smaller from system preferences.

Source

6
  • 9
    The config file is usually at /home/<user_name>/<neabeans_folder>/etc/netbeans.conf.
    – Bibhas
    Feb 22, 2012 at 12:15
  • 2
    Didn't work for me :(
    – szx
    Jul 20, 2013 at 5:41
  • The config file is in /etc/netbeans.conf The first line didn't work for me but the second one did the trick Nov 18, 2013 at 23:23
  • I'm not seeing any difference after adding this line. A . is still only one pixel, for example, where it shows up nicely in any other app.
    – NoBugs
    Dec 9, 2013 at 6:44
  • This one did the trick for me.
    – NiMeDia
    Dec 19, 2016 at 13:38
7

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

3
  • as a footnote: the "-J-Dsun.java2d.xrender=true" introduced some render glitches. setting it to false, fixed the render glitches when rapid scrolling, but did not impact the beautiful fonts.
    – Chris Holt
    Jan 31, 2014 at 18:46
  • A quick followup note: if the openjdk pacakage is updated ahead of the font-fixed one and you apply it, you can revert back like this: for openjdk-7-jdk, openjdk-7-jre and openjdk-7-jre-headless, uninstall them and then install the previous versions from the font fix repo. apt-cache policy <package> will show you the versions. i.e. apt-get remove openjdk-7-jdk openjdk-7-jre openjdk-7-jre-headless apt-get install openjdk-7-jdk=7u51-2.4.4-0ubuntu0.13.10.1ppa2 openjdk-7-jre=7u51-2.4.4-0ubuntu0.13.10.1ppa2 openjdk-7-jre-headless=7u51-2.4.4-0ubuntu0.13.10.1ppa2
    – Chris Holt
    May 7, 2014 at 17:23
  • can you attach image, how it looks like now?
    – Roman
    Jan 28, 2017 at 10:57
7

The anti-aliasing of the fonts are not working correctly in Ubuntu Java Swing applications.

Add:

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

to netbeans.config at the end of the netbeans_default_options string.

You can find the config file in the $NETBEANS_HOME/etc/ folder (e.g. /home/<user_name>/<netbeans_folder>/etc/netbeans.conf)

Example:

netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dnetbeans.logger.console=true -J-ea -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true -J-Dsun.zip.disableMemoryMapping=true -J-Dnetbeans.extbrowser.manual_chrome_plugin_install=yes -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd"
4
  • For me, the config file was located at /etc/netbeans.conf (and sym-linked from other places). Sep 12, 2017 at 10:06
  • Apparent source: rdeeson.com/weblog/159/fix-ugly-fonts-in-netbeans-under-linux -- worked for me
    – loxaxs
    Nov 21, 2017 at 1:05
  • For Manzaro Linux, the configuration file is /usr/etc/netbeans.conf.
    – cuspymd
    Jul 22, 2020 at 16:24
  • This worked for me, also in the MPLABX editor which is based on NetBeans. The file is located in /opt/microchip/mplabx/v5.45/mplab_platform/etc/mplab_ide.conf
    – Carlos
    Apr 8, 2021 at 23:31
3

It's not so bad that font..

However, this is a Java application and as a particular way of handling fonts.

If you want only to change font size, you can start Netbeans with "--fontsize" parameter:

netbeans --fontsize 12

If you want change the font type, it is a bit more hard changing environment parameters, and this article explains very well:

https://wiki.archlinux.org/index.php/Java_Runtime_Environment_Fonts

This is for ArchLinux but I think it will work also in Ubuntu as Java is a universal software.

2

Going one step further to manual ways, I have prepared a dedicated font named as "Ubuntu Mono Nohinting" to workaround a rendering issue with Java Swing applications such as NetBeans IDE, IntelliJ IDEA and PyCharm. The font hinting information has been stripped from the original Ubuntu Mono font family.

How to install

  • download the zip file from here
  • extract it
  • open *.ttf with Font Viewer to install.
  • or you can manually copy *.ttf into ~/.local/share/fonts/.

How to use

  • Select "Ubuntu Mono Nohinting" in editors' configuration.

Screenshots

Ubuntu Mono Font with PyCharm Monokai theme

Ubuntu Mono Font with PyCharm Monokai theme

Ubuntu Mono Nohinting Font with PyCharm Monokai theme

Ubuntu Mono Nohinting Font with PyCharm Monokai theme

2

I had the same issue on Ubuntu 12.04 and Netbeans 7.2.

I tried adding -J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd to netbeans.conf but it did not solved the problem.

Then I saw the issue comment regarding the line height at Netbeans bug 215785. Setting the editor line height to 1.0 along with AA settings in netbeans.conf solved my problem.

2

You can use JetBrains Runtime for font rendering.

  1. Download JDK - https://bintray.com/jetbrains/intellij-jbr/jbrsdk8-linux-x64/1638.3
  2. Extract to folder /home/user/jre
  3. Edit etc/netbeans.conf:
netbeans_jdkhome="/home/user/jre"
  1. PROFIT

After and before: https://bender.kr.ua/netbeans-and-fonts/

1

I was able to do this like so (I am using Ubuntu 12.10, worked on Ubuntu 13.04 as well):


Step 1 (This probably works in all Ubuntu versions):

First I cleaned up the menus using this plugin Tools -> Plugins -> Settings -> Add:

http://java-swing-ayatana.googlecode.com/files/netbeans-catalog.xml

Once that location is added, you need to install the plugin, by searching for Java Ayatana (the description will be in Spanish). This will make the top and context menu the same as the OS.


Step 2 (I don't know if this will work in all Ubuntu versions):

Next you probably want the projects fonts too look nicer, what I did to fix that was run this in the terminal: sudo apt-get install gnome-tweak-tool I launched it and chose a different default font Now Netbeans looks pretty!

Here is a screenshot:

enter image description here

1
  • Changing the 'Interface' font on the tweak tools did the trick for me. I only had problems with those texts (cut in half!)
    – Makiavelo
    Sep 23, 2016 at 8:17
1

Just saw this posts and tried to fix my fonts problem, I had also issue, I could choose only 4 fonts all were lame, and wondered what happened that netbeans give only 4 fonts to choose from and also lame font chooser box, I am a big fan of netbeans and I knew I can find solution here.

any way I followed all possible guid. I use Ubuntu 13.10 and netbeans 7.3 (yes I love the unstable stuff)

  1. create .font folder in my user folder.
  2. copied all fonts I had to that folder.
  3. added the following line to the netbeans.conf file

find it by running:

locate netbeans.conf

edit it and added the following inside the quotes as suggested above

-J-Dswing.aatext=true -J-Dawt.useSystemAAFontSettings=lcd --laf Metal
  1. run netbeans update which I think did the magic now I have beautiful font chooser and have more fonts to choose then code to write (unfunny joke).

I hope it will help you.

1

Personally, I think the overall default appearance of Netbeans on Linux is a bit disappointing especially considering how nice it looks on other platforms. Thankfully, changing the look & feel (LAF) can be done easily from inside the IDE. Depending on your selection, this will often improve the appearance of fonts.

To change the LAF, do the following: Click on Tools >> Options In the dialog box, select Appearance then the Look and Feel tab Simply select one of the LAFs. My preference is Nimbus, but you may prefer something else.

There are also two 'Dark LAFs' plugins available: Dark Metal and Dark Nimbus.

1

Add the following code to the end of the netbeans_default_options your netbeans.conf file.

-J-Dawt.useSystemAAFontSettings=on

This will make use of the system fonts.

0
#!/bin/sh

gsettings set org.gnome.desktop.interface font-name 'Ubuntu 10'
sh /home/xxx/netbeans-7.2/bin/netbeans &
sleep 5
gsettings set org.gnome.desktop.interface font-name 'Ubuntu 11'
1
  • 7
    Welcome to Ask Ubuntu! This answer would benefit substantially, if you were to edit it to add some explanation (or at least to tell the user exactly what to do with these lines). Oct 1, 2012 at 3:12
0

I myself have done a little different thing: in my case, speaking of NetBeans version 8.0.1, the problem was the JDK installed on the system (Oracle JDK 8.0). After moving to OpenJDK 8 nicer fonts appeared in the user interface elements.

I don't know if that is a good answer, because it may not work everywhere, but certainly - trying by switching JDK (be it OpenJDK or Oracle JDK) you may see a difference.

0

I've tried literally every solution that I could find and none worked except using a different default JDK for NetBeans.

Oracle's JDK doesn't render fonts well. OpenJDK also doesn't seem to work for NetBeans but works wonders for IntelliJ and its siblings.

The one that worked for NetBeans is called TuxJDK which is essentially OpenJDK enhanced for Java developers working on Linux. One of the enhancements is excellent font rendering.

Here's how to use it:

  1. Download TuxJDK binary from here. ("tuxjdk-static-8.92.03.tar.xz" at the time of writing)
  2. Extract the tar.xz wherever you like.
  3. Copy the location of the TuxJDK directory.
  4. Open netbeans.conf located in NetBeansInstallationDirectory/etc/.
  5. Find the line which starts with "netbeans_jdkhome" and replace the path with the one copied in Step 3.
  6. Fire up and NetBeans and treat your eyes with some beautiful fonts!

Before: NetBeans before using TuxJDK

After: NetBeans after using TuxJDK

0

Just install zulu jdk from http://zulu.org :)

2
  • What does it do?
    – PerlDuck
    Mar 30, 2018 at 12:41
  • The zulu jdk have improved font rendering. So it can give the same result as tuxjdk.
    – Arun
    Mar 30, 2018 at 12:44
-1

I was having the same issue on Mint 12. I solved it by entering the "Advanced Settings"->"Fonts" and reducing the default font from 11 to 10. I lowered all the fonts in the list to consistency.

There must be some problem with the Cantarell 11 font.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .