Thursday, July 2, 2015

Subpixel font rendering with Netbeans on OSX

If you've been waiting to get subpixel font rendering with Netbeans on OSX, here a solution for you.

You will need to use current nightly Netbeans development branch (as of June 19th, 2015), and you will need to download, patch and build OpenJDK 9. Now, the latest build b70 support subpixel rendering, but not with translucent surfaces, which netbeans uses a lot of. When you're done, you will be able to get proper weighted fonts as shown above, with smooth scrolling even on a macbook pro with integrated Intel Iris Pro graphics hardware.

Here are the steps you need to take;

1. Download, patch and build OpenJDK 9

You can follow instruction here on how to do it, but I've outlined it below:

2. While compiling, listen to Mozart to prepare for the enlightenment. 

When the build is complete, the jdk home will be in the build/macosx-x86_64-normal-server-release/jdk/ folder. Now edit a file under your netbeans nightly folder, in my case 

vi /Applications/NetBeans/NetBeans\ Dev\ 

Add this line at the end of the file (modified for the exact location where you built openJDK).


Now you can start netbeans normally.


  1. Hey, thanks I did it but netbeans is not starting when using the path to the new jdk
    any ideas?

  2. Hi, you can try running netbeans in a terminal using a command like

    /Applications/NetBeans/NetBeans\ Dev\

    adjusted for your exact path of course. Did your OpenJDK build complete without errors? You can always try the 'make all' command again to make sure it completed the build.

    1. This comment has been removed by the author.

    2. Ok so I had forgotten to install the nightly build. I did and it started up but the scrolling is even worse than the scrolling in Netbeans 8.0.2 that is available right now. Thanks anyway :)

    3. No error messages of any sort in the terminal when that happens?

    4. If the scrolling is worse, check if you applied both patches. I forgot to include the patch that speeds up subpixel rendering when i first made the post. The extra patch you need is this one;

      curl | patch --dry-run -p1

  3. Hi, I found this error:
    Unrecognized VM option 'PermSize=32m'
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.

    1. I had it the same when not using the nightly build. Thats it:

  4. Thanks for this. It looks amazing now (apart from the weird double-print on the bottom bar. I will agree the scrolling is pretty slow. (Using both patches.) But, at least it looks like it's supposed to. Thanks for the walkthrough!

    1. Which graphics hardware do you have? Apparently the fix doesn't give the same speedup on all hardware, see

  5. Same here - sharp, but now very slow at scrolling to the point it's not usable. MBP 15" Retina, 256GB SSD, 16GB memory.

    1. If scrolling is slow, you might try running on the integrated intel iris pro graphics. Download gfxCardStatus from and change mode in the menubar. I sometimes see slower performance under certain conditions with the nvidia hardware, and sometimes faster scrolling with intel iris pro.

      Also , there's been some issues with the openjdk 9 not building under OSX yosemite but I've been unable to find out why yet.

      Lastly, if you just want faster scrolling but can forgo the subpixel antialiasing, try reverting the patch that enables subpixel antialiasing for translucent surfaces.

  6. OpenJDK 9 b76 seems to contain the fix for bug 8087201 to enable faster LCD text rendering, so that patch is no longer required. If you just want faster rendering without subpixel font rendering, try OpenJDK 9 b76.

    I'm amending the build instructions since that patch is then no longer needed.

  7. For me quick fix was to install the netbeans 8.1 beta and JDK 1.9 early access, then reconfigure the beta to use the newer JDK - e.g.

    nano /Applications/NetBeans/NetBeans\ 8.1\

    then edit the path (first is the original value commented)

    # netbeans_jdkhome="/Applications/NetBeans/NetBeans 8.1"


  8. Hi, I did this today but the performance of Netbeans is horrible, and not stable. Is there a specific version optimal for this patch? I see that you say b70, but maybe things have changed since then.

    This is the only blog post discussing the issue and I see that it was also you on the bug tickets :) I can't believe nobody else recognizes such a terrible issue. Netbeans is not usable at OSX.

    1. I don't think there's a specific version that is better or worse for the patch, I just run with the latest myself. b70 should be sufficient.

      I've seen performance drop on intel integrated gfx, when the computer runs low on available ram. Are you using intel integrated, or nvidia graphics?

    2. It shouldn't be an issue, I think. The GPU is Nvidia GeForce GTX 980 Ti, I don't know which graphic card can handle it if this one can't :)

      I've also tried with the latest JDK 1.9 early access and Netbeans 8.1 RC but I think the latest JDK doesn't have the patch you specified. Do you know of a configuration or a flag to make it happen? Maybe another way could be to tell Netbeans not to use translucent surfaces, do you think is that possible?


    3. The latest 1.9 early access release does contain the rendering speedups (, but not the actual patch that enables subpixel rendering for translucent surfaces (the one in my gist file). There is a jdk bug tracking the issue of supporting subpixel rendering on translucent surfaces, but it's currently private for some reason;

      The bug for the rendering speedups contains quite a few benchmark tests, and some of them shows actual slowdowns on some particular nvidia graphics processors.

      If you compare the benchmark for the 9600m and intel integrated (, files mbp-10.8-NVGF9600M.txt and mbp-intel-iris.txt respectively), you see that while the intel graphics shows benchmarks speeds like 3000% (ie 30 times faster), the 9600M often renders slower with the new code.

      From the JDK mailing list:

      "Unfortunately, the effect of the fix highly depends on graphics hardware capabilities: on some system the price of synchronized access to a texture is too high, and it may eliminate any performance benefits.

      For example, on iMac with ati rradeon hd6750m our benchmarks show increasing the rendering speed to 7-10 times, but it barely enough to smooth rendering. I am still looking for another possible solutions."


      "* Increase dimension of the glyph cache cell from 16x16 to 32x32.
      >>> This change gives significant performance boost on systems with retina
      >>> (because of average size of rendered glyphs).
      >>> However, on systems where the fast path with destination texture is not
      >>> possible for any reasons, this change may cause a performance
      >>> degradation
      >>> because of more extenceive usage of glCopyTexSubImage2D.
      >>> So, we probably may want to get a means to configure the cell dimension
      >>> depending on system capabilities."

      Note that the rendering slowdown on the 9600M seems to be due to it missing the OpenGL texture barrier extension needed for it to work.

      This is probably a lot more information than you wanted. The GTX 980 Ti I assume is either in a Mac Pro, or in a Hackintosh computer, in which case I cannot understand why you would have issues with the rendering speed compared to netbeans under jdk 8.

      Regarding telling netbeans not to use translucent surfaces, I don't think its possible with the current code. I've seen a comment indicating they're investigating reimplementing the editor drawing code to speed up rendering. It might or might not be possible that that work would result in changes in how they configure the use of rendering surfaces.

    4. Just another comment I came over about

      ">> * NV
      >> here the fix causes significant performance degradation. A reason
      >> of this is
      >> is not clear to me yet. Probably it is due to significant overhead
      >> on synchronization:

    5. Thank you very much, I think this information will be very helpful for future researchers on this subject :)

      Yes it's a Hackintosh, and I conclude that I'm out of luck currently. The bug is there for 5 years and may be it will be there for a while. Probably it's not that bad on retina displays and that's why it goes undetected. But you know, font rendering is very important on editors and it's a shame Netbeans and/or Java can't handle it currently.

      Thanks again.