The Problem Causing Squares in Eclipse Instead of Actual Code

How to fix a frustrating problem with Fonts in Ubuntu Gnome and Eclipse. Possibly also affecting other Linux distributions.

989 views
d

By. Jacob

Edited: 2017-08-19 03:57

Recently I had to fix a problem with fonts where even normal letters would show as squares in Eclipse on my Ubuntu Gnome laptop. Typically it would result in key names of associate arrays, as well as method, and function names being displayed as unreadable boxes instead of code, almost as if there was a problem with the encoding. The PHP opening tags "<?php", was also affected by the bug.

I somehow guessed the problem had to be with the fonts, and then I saw other people discussing the same problem. Supposedly, Ubuntu Gnome for some reason does not install all the required fonts, and this causes some applications to unexpectedly break, characters showing up as squares instead of the actual characters. I am sure the files are encoded as UTF8, so this was not what caused the problem. I was able to guess that it could be a font issue, but other users may not be that lucky.

It is very confusing that there is no message indicating that there is a problem loading fonts, it leads people to think the encoding of their files is messed up! Logically, however, a script would obviously fail if there was a encoding problem this severe, so it had to be something else causing the problem.

Reinstall fonts in Ubuntu

To reinstall the fonts, you may run the below commands:

sudo apt-get install --reinstall ttf-ubuntu-font-family && fc-cache -f -v

This should hopefully fix the problem, and allow you to get back to your coding.

Note. This bug may also affect other Linux distributions. Check how to install fonts with the documentation of your own distribution.

Tell us what you think:

  1. How to create a simple .desktop launcher for Eclipse in Ubuntu Gnome, and add it to your favorites.
  2. How to fix a problem with PHP files and an empty outline in Eclipse.

More in: Eclipse