3

How to run a X11 only app with user defined font size and font style ?

Is it possible to run different X11 apps with different font size and style ? e.g. Run xclipboard with font FreeSans 14px and run xman with Roboto 12px .

Is there any environment variable available to override font settings of GUI apps ? like

env FONT_SIZE="16px" xterm

2 Answers 2

4

Classic X11 applications

For classic X11 applications (such as xclipboard, xman, xterm, etc.), yes, there is a way, through X resources. X resources settings are conventionally stored in a file called ~/.Xresources which is loaded by the command xrdb -merge ~/.Xresources during the startup of your session (not all environments load it by default though).

You can find examples of X resource settings in the app-defaults directory (the exact location can vary: /usr/share/X11/app-defaults, /usr/X11/lib/app-defaults, /etc/X11/app-defaults, …). These are the system-wide settings for each application. You can also run appres to list the user-defined settings loaded in the server plus the system-wide settings in app-defaults, e.g. appres Xman. Note that app-defaults files and appres output omits the class name, but in your own configuration file, you should start every setting with a class or instance name, otherwise the setting will apply to every application.

A resource setting consists of a qualified widget component name and a value, e.g. XClipboard.form.text.textSink.font: fixed. See .Xresources settings in effect and the manual for more information on resource identifiers. Note that X resources are case sensitive. Conventionally, class names start with an uppercase letter, and instance names start with a lowercase letter. You can use the wildcard * to stand for any number of components, e.g. XClipboard*font would set all fonts in XClipboard.

Note that classic X11 applications use server-side text rendering. They do not have the same fonts available as applications that use client-side rendering with fonts managed by fontconfig. You can use xfontsel to see what fonts are available server-side. X11 fonts use a 14-part naming scheme encoding the font, size, boldness, etc.; see the manual for detail.

Most classic X11 applications support resource settings on the command line, with arguments like -xrm '*text*font: fixed', as well as some shortcuts such as -font fixed to set the main font. Xterm supports those, and in addition supports client-side rendering, which can be set through resources or through the command line argument -fa (see the manual for details).

GTK applications

The GTK font is normally set by the theme and can be overridden in ~.gtkrc.

gtk-font-name = "Roboto 12"

You can run an application with an alternate gtkrc file or alternate theme through environment variables. With the older Gtk2:

GTK2_RC_FILES=/path/to/alternate/gtkrc my-gtk2-app

The newer Gtk3 is expectedly less configurable, but you can use an alternate theme:

GTK_THEME=/path/to/alternate/theme.css my-gtk3-app

You can also look for application-specific settings with gconf-editor (GTK 2) or dconf-editor (GTK 3) or gsettings. I don't think it's common for GTK applications to have specific font settings though.

0

based on the answer above by Gilles 'SO- stop being evil'.

to increase font size in xclipboard:

  1. append the line XClipboard*font: -*-*-*-*-*--*-480-*-*-*-*-*-* to ~/.Xresources. the field with the number 480 controls font size.
  2. activate the new setting by running xrdb -merge ~/.Xresources
  3. run xclipboard

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .