Font in remote X connection

Font in remote X connection

I have a headless Gentoo box and would like to run X app on it but forward the display to a Cygwin Xorg server running on my Windows PC.

It works but I am not sure in this case if I specify some fonts to use in the X app, which font will be actually used? the one on the Gentoo box(where the X app is running)? or the one installed in my Cygwin (where the X app is being displayed)?

For example I want to use font DejaVu Sans Mono in urxvt, my ~/.Xresources on the Gentoo box looks like this:

URxvt*font: xft:DejaVu Sans Mono:size=12

On the Gentoo box I have the font installed and enabled. The following is the output of eselect fontconfig list

  [1]   10-autohint.conf
  [2]   10-no-sub-pixel.conf
  [3]   10-scale-bitmap-fonts.conf *
  [4]   10-sub-pixel-bgr.conf
  [5]   10-sub-pixel-rgb.conf
  [6]   10-sub-pixel-vbgr.conf
  [7]   10-sub-pixel-vrgb.conf
  [8]   10-unhinted.conf
  [9]   11-lcdfilter-default.conf
  [10]  11-lcdfilter-legacy.conf
  [11]  11-lcdfilter-light.conf
  [12]  20-unhint-small-dejavu-sans.conf
  [13]  20-unhint-small-dejavu-sans-mono.conf
  [14]  20-unhint-small-dejavu-serif.conf
  [15]  20-unhint-small-vera.conf *
  [16]  25-unhint-nonlatin.conf
  [17]  30-metric-aliases.conf *
  [18]  30-urw-aliases.conf *
  [19]  40-nonlatin.conf *
  [20]  45-latin.conf *
  [21]  49-sansserif.conf *
  [22]  50-user.conf *
  [23]  51-local.conf *
  [24]  57-dejavu-sans.conf
  [25]  57-dejavu-sans-mono.conf *

Then run xrdb on the Gentoo box to enable the resource (this makes me believe the font on Gentoo box will be used):

xrdb ~/.Xresources

When I start urxvt it complains:

urxvt: unable to load base fontset, please specify a valid one using -fn, aborting.

UPDATE As grawity has pointed out, it turns out my urxvt was built without xft support. It is solved after I append xft to the system wide USE. Thank you very much!

答案1

It works but I am not sure in this case if I specify some fonts to use in the X app, which font will be actually used? the one on the Gentoo box(where the X app is running)? or the one installed in my Cygwin (where the X app is being displayed)?

Both.

While I'm not sure about the exact rules which fonts are used when, the basics are:

  • If the program uses XLFDs to select fonts, then it usually lets the X11 server (i.e. Xorg, Xwin.exe, or such) draw them. They need to be installed in the server; you can use xset q to query the server's current "font path".

  • However, modern programs render fonts client-side using FreeType + {Xft, cairo, Qt} [+ {Pango, HarfBuzz}]. In this case, fonts need to be installed on the client, and Fontconfig is used to find them.

In your case, using xft: in urxvt means the client-side (Gentoo) fonts will be used. (Cygwin's Xwin is the server, urxvt on Gentoo is the client, according to the usual X terminology.)

However, normally urxvt does not display any errors when an unknown xft: font is given. So I have a guess that your urxvt is actually built without Xft support at all. Run ldd /usr/bin/urxvt and check whether it's linked to libfreetype and libXft.

相关内容