Ubuntu – Android Studio doesn’t render Ubuntu Mono Font well

android-studiofontsjavaubuntu-font-family

It doesn't even recognise it as a Monospaced font. Then it only shows anti-aliasing when the font size is set to 20 or over. But for other fonts it does it at 16.

The result is ugly looking fonts and eye-strain when set to 16, which is still large.

I am using these settings in studio64.vmoptions file

-Dawt.useSystemAAFontSettings=lcd
-Dswing.aatext=true
-Dsun.java2d.xrender=true

I have tried various settings for Dawt.useSystemAAFontSettings and still the same issue.

Ubuntu Monospace font looks fine in Eclipse and other text editors.Where in Eclipse it's size 12 and it renders fine.

Here are some screenshots Ubuntu Mono 16 :Ubuntu Mono 16

Ubuntu Mono 20
Ubuntu Mono 16

Source Pro 16 (I think comes with Studio)
Source Pro 16

Ubuntu Mono 12 in Eclipse (ideal for me)
Ubuntu Mono 12 in Eclipse

I have uploaded the images to imgur as this site is compressing the images, and the quality is affected.

Is there another setting that is controlling what size to turn on anti-aliasing on a font. Is there a way to control the dpi setting used in the Android Studio.

Anyone else have other font recommendations. I have tried droid mono, and other default ones that come with Ubuntu.

I am using Android Studio 0.86, Oracle's Java 7 on Ubuntu 12.04 with Nvidia drivers.

Best Answer

The problem is not anti-aliasing - all of your examples show the text is anti-aliased fine.

The difference is in an aspect of font rendering called "hinting" - the top Ubuntu Mono example shows a strong hinting, whereas the bottom Ubuntu Mono example shows a smoother hinting. Hinting deforms the letter shapes to better align to the pixel grid and give a more crisp appearance.

Whether you like one or the other is a matter of personal preference. The top one is certainly very clear to read but at the expense of deforming the letter shapes.

The Java environment will be using its own font renderer rather than your global settings, hence the difference.

There are various fixes for this described in this link at stackoverflow.com:

https://stackoverflow.com/questions/17510099/ugly-fonts-in-java-applications-on-ubuntu

This one looks pretty simple (I have not tested this):

Try adding

export _JAVA_OPTIONS='-Dawt.useSystemAAFontSettings=gasp'

to your ~/.bashrc

But the chosen solution is more complex.