Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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? Thanks in advance!

share|improve this question
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. – Jamie Schembri Mar 30 '11 at 18:00
Yes it seems to affect only java based apps, I'm thinking about changing my IDE just because of this.. – javiervd Apr 5 '11 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. – Jamie Schembri Apr 6 '11 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. – javiervd Apr 8 '11 at 3:55

8 Answers

up vote 16 down vote accepted

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 somewhere on the web (would love to link the page, but I cannot find it): 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 to select all characters
  5. Hints -> Clear instructions
  6. Ctrl + Shift + F 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
  9. Clear font cache fc-cache -rv
  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.

share|improve this answer
Thanks! Worked out very well! – forker Mar 20 '12 at 21:31
1  
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 '12 at 23:16

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

share|improve this answer
3  
The config file is usually at /home/<user_name>/<neabeans_folder>/etc/netbeans.conf. – Bibhas Feb 22 '12 at 12:15

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.

share|improve this answer

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 the 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 to netbeans.conf solved my problem.

share|improve this answer

Changing the application font can do the trick. See post from Thiago here: http://stackoverflow.com/questions/5660515/how-to-fix-netbeanss-look-on-ubunbu?s=86800e58-ba6b-44c4-b762-2468e999005b#new-answer

share|improve this answer
2  
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – Mahesh Aug 11 '12 at 13:19
#!/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'
share|improve this answer
4  
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). – Eliah Kagan Oct 1 '12 at 3:12

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!

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.