Fix: Gitg doesn't use monospace font in Ubuntu

In my work, I always use Git as command line. But I often use a GUI program to have better view on version history. Gitg is my usual choice.

Since the inclusion of Gtk3-based Gitg in Ubuntu, some annoying bugs have started to appear. One is that Gitg's source view doesn't respect Monospace font setting of the desktop environment.


I filed a bug report to Gitg developers, but it seems that it is Ubuntu theme problem, so no fix for Gitg is given.

Looking more around, it is confirmed that Ubuntu's theme, Ambiance, doesn't support GtkTextView::monospace of Gtk 3. A possible solution is that the application has to explicitly choose the font. But Gitg developers seem not to be active in this issue. I cannot wait them for a fix. So I look for hacking in Ambiance theme.

Here is my fix.

Look for the CSS files of Ambiance theme. My choice is the /usr/share/themes/Ambiance/gtk-3.20/gtk-widgets.css file. Add this code to the end of the file:

/* Fix Gitg source view */
.monospace {
    font-family: "Monospace";

Save the file and open Gitg again. Bravo, it works:


I've just filed a bug report to Ubuntu. Hope this will be officially fixed soon.

Website này sử dụng Disqus cho comment. Nếu bạn không thấy các comment dưới đây, có lẽ Disqus đang bị chặn. Bạn cần đổi DNS.