Smaller font sizes for Eclipse on Linux

September 24, 2008

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 GRK/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 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. 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

Pros:

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

Cons:

  • Launching eclipse from command line (although you can create an icon on your desktop).

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.

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 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.
  • Easily portable to other machines.
  • Configures all GUI elements at once.

Cons:

  • Again, launching eclipse from command line (although you can create an icon on your desktop).

Entry Filed under: Eclipse, Linux, planetLTC. .

3 Comments Add your own

  • 1. pedrotech  |  November 19, 2008 at 10:19 am

    Very nice trick!

    There’s a typo in your gtkrc file.

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

    Reply
  • 2. kadirmalak  |  February 18, 2009 at 1:01 pm

    Nice and clean.
    Thanks…

    Reply
  • 3. Alban Browaeys  |  October 15, 2009 at 10:42 pm

    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.

    Reply

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Disclaimer

This is the technical weblog of Daniel Felix Ferber. The postings on this site are his own and don’t necessarily represent neither IBM’s, Stefanini IT Solutions nor Petrobras positions, strategies or opinions.

My Personal Weblog

This weblog is dedicated for my technical articles written in English. If you are interested in my personal thoughs, or my articles in Portuguese, please visit Daniel Ferbers Weblog.

Blogroll

Feeds

Pages

 

September 2008
M T W T F S S
« Aug   Oct »
1234567
891011121314
15161718192021
22232425262728
2930  

Archives

Meta