Smaller font sizes for Eclipse on Linux

This article describes some approaches to launch Eclipse on Linux with smaller font sizes and customized graphical user interface (GUI).

The modern desktop environments like KDE or Gnome use larger font sizes to enhance readability of screen contents. However, Eclipse, looks better with a clean design and small fonts.

Views like Package Explorer or Outline may contain very large listings of important information. Eclipse uses are not willing to waste precious space neither with large fonts nor with fancy window decorations.

Customizing window manager and themes

GTK and Gnome offer nice dialogs to customize decorations and font sizes. There is also a QT-GTK on KDE binding that applies KDE design on GTK/Gnome applications.

The naive approach is reducing the global font size for the applications.

Pros:

  • Easy for newbies

Cons:

  • The changes affect all applications, while we want to preserve default font and decorations for (most of) them. Thunderbird and Firefox will look very annoying with small fonts.

Customizing eclipse GUI

Another approach is configuring each GUI element individually in details from within Eclipse preferences dialog (Menu Windows->Preferences, tab General->Appearance->Color and Fonts). See documentation.

Pros:

  • Reasonably easy, once you understand the preferences “Color and Fonts” dialog.
  • Affects only Eclipse, while other applications keep the default font and decorations.

Cons:

  • The customization keeps restricted to the workspace. On new/other workspaces, all customization is reseted.
  • There are many, many items to change manually.
  • For some mysterious reason, it is not possible to set font for the content of views.

Too bad! It happens that the content of views requires the largest amount of space (specially horizontal space). There is no use in reducing font sizes for other GUI elements while it is not possible to reduce font in views.

Loading eclipse with another theme

Eclipse inherits GUI configuration from the GTK engine (assuming you have downloaded eclipse-gtk, and not eclipse-motif). It is possible to set the GTK-theme with the GTK2_RC_FILES environment variable. You may point to a gtkrc file with a less space consuming theme.

For example, Raleigh is a nice looking, but clean theme. I also Like the Clearlooks theme. Both are very simplistic, the do not waste space with fancy borders or shadows. Often, by using the default Gnome theme, you are prevented from recognizing which item is selected in menus, lists and combo boxes, because the them uses the same font color as the background color on the selected item. Both Raleigh and Clearlooks solve this issue.

Launch eclipse as follows (changing paths according to your eclipse installation):

GTK2_RC_FILES=/usr/share/themes/Raleigh/gtk-2.0/gtkrc /opt/eclipse-3.3/eclipse

or, if you are creating a icon for your desktop (thanks Alban Browaeys for this advice!):

env GTK2_RC_FILES=/usr/share/themes/Raleigh/gtk-2.0/gtkrc /opt/eclipse-3.3/eclipse

Pros:

  • Affects only eclipse, but on all workspaces,
  • Configures all GUI elements at once.

Cons:

  • Due to Alban Browaeys advice, I have no cons anymore.

My favorite: Overwriting the theme

Although it is theoretically possible to create a new GTK theme from scratch just to launch eclipse, this would require an extraneous amount of work. Or you can create a modified copy of your preferred theme, but this would not easily portable to other machines or to newer versions of GTK. It is much easier to use an existing theme, just overwriting some parameters (the font and size).

Somewhere on your home directory, create a gtkrc file (like: ~/.gtkrc-eclipse) with following content:

style "eclipse" {
        font_name = "Sans Condensed 8"
}
class "GtkWidget" style "eclipse"

Finally, to launch eclipse, use following command line:

GTK2_RC_FILES=/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:/home/user/.gtkrc-eclipse '/opt/eclipse-3.3/eclipse'

(note: the command above shall be written as one line)

or, for a desktop icon:

env GTK2_RC_FILES=/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:/home/user/.gtkrc-eclipse '/opt/eclipse-3.3/eclipse'

(note: the command above shall be written as one line)

Note that GTK loads the gtkrc files in the order that they appear in the GTK2_RC_FILES variable. Files to the right may overwrite configuration from files to the left. In this case, the .gtkrc-eclipse file overwrite the font settings for elements based on GtkWidget (that means, all GTK widgets).

Pros:

  • Affects only eclipse, but on all workspaces.
  • Configures all GUI elements at once.
  • Easily portable to other machines.
  • Reuses work of someone who is surely better in graphical design as you.

Cons:

  • As far, no that I knew.

45 Responses to Smaller font sizes for Eclipse on Linux

  1. pedrotech says:

    Very nice trick!

    There’s a typo in your gtkrc file.

    style “eclipse” {
    font_name = “Sans Condensed 8”
    }
    class “GtkWidget” style “eclipse”

  2. kadirmalak says:

    Nice and clean.
    Thanks…

  3. Alban Browaeys says:

    And for to make a launcher (desktop file), the command is:
    env GTK2_RC_FILES=… eclipse

    Replace … with your GTK2_RC_FILES setting.

    Note the “env” otherwise environment variable setting break the Exec desktop file entry.

    • Daniel Ferber says:

      Thanks, Alban, for this advice! Really useful, it solved the only “cons” that remained on the proposed solution.

  4. Great tip. I found this very useful for teaching, where I want a LARGER font size so that students in the back row can read everything. I then had to change the Basic -> Text font size to be larger. I wish there was a way to do that from outside Eclipse as well.

  5. Thibaud says:

    Very, very usefull tip.
    Overriding the theme works perfectly.
    Thanks a lot.

  6. Steve Cohen says:

    Under “My favorite: Overwriting the theme”, you start by instructing us to create a file called “~/.gtkrc-eclipse” with certain content.

    You then go on to say to launch eclipse with this:
    “GTK2_RC_FILES=/usr/share/themes/Clearlooks/gtk-2.0/gtkrc:/home/user/.gtkrc-”

    Did something get cut off and should this end with “/home/user/.gtkrc-eclipse”? Or am I missing something?

    Also, the command line and desktop icon command lines are identical.

    • Daniel Ferber says:

      Thanks for pointing this out. I happens that the my current wordpress theme is cutting long lines instead of wrapping them. I split the comment into two lines in order to fit into available space.

  7. Steve Cohen says:

    Most of my comment above can be disregarded. However, I must point out that this page renders differently browser by browser, hiding the true solution from the Linux users who need it!

    My comments were apropos of how the page looked under Google Chrome browser. It looks different under Firefox under Linux, and still different under Firefox under Windows. However, only under Internet Explorer does your page render your intent correctly and show me a workable solution.

    So thanks for the solution.

  8. Steve Cohen says:

    Much better now.

    One minor tweak more perhaps your graphical wizardry may help me with?

    Is there a further line I could add to .gtkrc-eclipse that would adjust the sizings of things like tabs and toolbars in synch with the smaller size? I find these to act as if they were still trying to handle the larger font size.

  9. Pingback: Rita's Blog » Smaller font sizes for Eclipse on Linux « Daniel Ferbers Technical Tavern

  10. Mat Dodds says:

    Thank you for this detailed tweak – working with Eclipse on my laptop is now much easier.

  11. Aldo Fernandez says:

    This tutorial is great!
    Thx Daniel for your time and dedication! Going to browse your archives for more great stuff!

    Just as a suggestion for other users… I modified the .gtkrc-eclipse file with:

    style “eclipse” {
    font_name = “Droid Sand Mono 9”
    }
    class “GtkWidget” style “eclipse”

    Looks really smooth.

    Regards,
    –Aldo

  12. Fred says:

    Awesome! Thanks!

  13. martin says:

    Much appreciated.

  14. fred says:

    wonderful! thank you for this tip!

  15. Gish says:

    It would be amazing if you could update this for gnome 3 and ubuntu 11.10

  16. chris says:

    Works great with eclipse version 3.6.2!
    Our admin changed now to eclipse 3.7.1 and the
    .gtkrc-eclipse unfortunately does not work any more.

    Does anybody now a solution?

    Regards,
    Chris

    • nutate says:

      I have it working with Indigo. I don’t believe I did any tricks, besides including clearlooks directly.

      include “/usr/share/themes/Clearlooks/gtk-2.0/gtkrc”
      style “eclipse” {
      font_name = “Droid Sans Mono 8”
      }
      #widget_class “*” style “eclipse”
      class “GtkWidget” style “eclipse”

      (the commented out widget_class works too) I then fire it up with:

      GTK2_RC_FILES=/home/nutate/.gtkrc-eclipse /home/nutate/bin/eclipse/eclipse

  17. Tamas Imrei says:

    nice’n’easy! thanks!

  18. Gaziz says:

    Thank you! My favorite is the trick with desktop icon.

  19. Juanjo Garcia says:

    If you add the font config code to $HOME/.gtkrc-2.0 and start eclipse you will also get it (without using any GTK2_RC var). At least on debian wheezy.

    Trick:
    cat /proc/ECLIPSE_PID/environ and search for GTK2_RC_FILES var and see which files are loaded by default

  20. That worked great. Thanks very much.

  21. alynch4047 says:

    Thanks for this, very useful indeed.

  22. Milind says:

    On Fedora17 selecting the Classic them + Setting the fonts to small size works. I got a clean and professional looking Eclipse. I can share the settings.

  23. j03 says:

    AWESOME!
    thank you.

  24. mSquare says:

    Thanks ! Woked for me on Eclipse Juno Ubuntu 12.10.
    I also used the following link to set the tab fonts.. which were still too big…
    http://blog.nanthrax.net/2012/07/change-tab-font-in-eclipse-juno/

  25. indraforyou says:

    Hi,
    Thanks again for this post.

    After a bit more searching and digging in, I could trim some more space.

    Here is my .gtkrc-2.0

    style “gtkcompact” {
    font_name=”Sans Condensed 8″
    GtkButton::default_border={0,0,0,0}
    GtkButton::default_outside_border={0,0,0,0}
    GtkButtonBox::child_min_width=0
    GtkButtonBox::child_min_heigth=0
    GtkButtonBox::child_internal_pad_x=0
    GtkButtonBox::child_internal_pad_y=0
    GtkMenu::vertical-padding=0
    GtkMenuBar::internal_padding=0
    GtkMenuItem::horizontal-padding=0
    GtkToolbar::internal-padding=0
    GtkToolbar::space-size=0
    GtkOptionMenu::indicator_size=0
    GtkOptionMenu::indicator_spacing=0
    GtkPaned::handle_size=0
    GtkRange::trough_border=0
    GtkRange::stepper_spacing=0
    GtkScale::value_spacing=0
    GtkScrolledWindow::scrollbar_spacing=0
    GtkExpander::expander-size=0
    GtkExpander::expander_spacing=0
    GtkTreeView::vertical-separator=0
    GtkTreeView::horizontal-separator=0
    GtkTreeView::expander-size=0
    GtkTreeView::fixed-height-mode=TRUE
    GtkWidget::focus_padding=0
    }
    class “GtkWidget” style “gtkcompact”

    style “gtkcompactextra” {
    xthickness=0
    ythickness=0
    }
    class “GtkButton” style “gtkcompactextra”
    class “GtkToolbar” style “gtkcompactextra”
    class “GtkPaned” style “gtkcompactextra”

  26. hussein hammoud says:

    Guys how to make the change permanent ?
    Thanks :)
    Great tutorial I appreciate it :D

    • Eugene says:

      edit the /usr/bin/eclipse file, at the very beginning add the line to the file:

      #!/bin/sh

      export GTK2_RC_FILES=/home/user/gtkrc-eclipse

      ECLIPSE=/usr/lib/eclipse/eclipse

  27. Richard says:

    This didn’t work for the tab font sizez for me (using Kepler), I had to edit the css file : http://wiki.eclipse.org/Eclipse4/CSS#Reducing_the_tab_font_size

  28. Works great for Kepler too.

  29. Chris says:

    Works great for Aptana Studio 3 also. Thanks!

  30. Pingback: Tyranus-Blog » Kleinere Schriftarten in Eclipse unter Linux

  31. Torsten says:

    Very useful, thanks for sharing!

  32. Pingback: configure font size for tree item in package explorer in eclipse | Coding and Programing

  33. my .gtkrc-2.0 content for Luna

    style “eclipse” {
    xthickness = 0
    ythickness = 0
    GtkButton::default_border={0,0,0,0}
    GtkButton::default_outside_border={0,0,0,0}
    GtkButtonBox::child_min_width=0
    GtkButtonBox::child_min_heigth=0
    GtkButtonBox::child_internal_pad_x=0
    GtkButtonBox::child_internal_pad_y=0
    GtkMenu::vertical-padding=1
    GtkMenuBar::internal_padding=0
    GtkMenuItem::horizontal_padding=4
    GtkToolbar::internal-padding=0
    GtkToolbar::space-size=0
    GtkOptionMenu::indicator_size=0
    GtkOptionMenu::indicator_spacing=0
    GtkPaned::handle_size=4
    GtkRange::trough_border=0
    GtkRange::stepper_spacing=0
    GtkScale::value_spacing=0
    GtkScrolledWindow::scrollbar_spacing=0
    GtkTreeView::vertical-separator=0
    GtkTreeView::horizontal-separator=0
    GtkTreeView::fixed-height-mode=TRUE
    GtkWidget::focus_padding=0
    font_name = “Sans Condensed 9”
    }

    class “GtkWidget” style “eclipse”

  34. Nice and very useful.

    I was struggling for package explorer and outline font size config, the last method of gtk-rc works fine.

    Thanks,

  35. Pingback: How can I change line height / line spacing in Eclipse? | ASK AND ANSWER

  36. Peter Keller says:

    This worked great for Luna, but stopped working for me with Mars and Neon (which use gtk+ 3). I tried a bit of tweaking, but without success. According to https://developer.gnome.org/gtk2/stable/gtk-running.html GTK2_RC_FILES is read by gtk+ both 2 and 3.

    Has anyone managed to do something like this for Eclipse version 4.5 or later? I am particularly interested in shrinking the font size in navigator views

  37. Pingback: How can I configure the font size for the tree item in the package explorer in Eclipse? - PhotoLens

Leave a comment