Archives / Search ›

Fonts and NX

For several years, I’ve been using a combination of Screen and NX as a detachable research environment. Since I started working on Jython and using Mercurial, I’ve been able to do more work on the Mac locally (especially with Eclipse, which isn’t fun in NX) then easily sync up to our Linux research machines when necessary for timing runs, or to use Pin or Simics. So while my need for NX has been reduced, I still need it several times a week.

I’ve very much had a love-hate relationship with NX. It works so much better than the alternatives such as VNC, RDP or using TRAMP with Emacs. But NX is also flaky and fragile, with bugs like insisting on a specific ordering of bit depths. NX forks OpenSSH and various X components, then fails to keep up to date with recent changes in each. Coordination between the various components is haphazard at best. The Mac NX client front end is still a PowerPC app compiled against an ancient version of Qt.

It’s hard to diagnose problems when NX fails by refusing to resume, losing, or worst of all, destroying your session. A multitude of log files exist—for the client, look in ~/.nx/temp—but require you distinguish expected brokenness from unexpected brokenness, only possible if you have a working setup to compare against.

Fonts are a particular sticking point. The NX developers really want client-side fonts to go away, but both of the X clients I tend to run in NX (rxvt and Emacs) use client-side fonts, so I don’t really have a choice. Some points to be aware of:

  • If an X client is using a font and it isn’t available to the local X server (NX client machine) when you try to resume a session, in the best case you’ll get a font like fixed substituted or see a bunch of boxes in place of your characters. In the worst case the session will be destroyed. Be careful.

  • The documentation claims you must have the same set of fonts accessible on both the (NX) client and server, in order for them to be accessible and usable. Don’t forget to run mkfontdir—on OS X, this sometimes runs for you. However, sometimes a font can appear in xlsfonts because it used to be accessible; in this case it’ll either display a scaled bitmap or a substituted font.

  • At least on the Mac, there’s no guarantee that a font which appears in xlsfonts locally is actually available to NX. I don’t quite understand what’s going on here, but if you put your font in one of the default font directories (what’s displayed when you run xset fp default; xset q), run mkfontdir and xset fp rehash if necessary, then attach your NX session, it’s likely to work. On one of my Macs and user accounts, I can get it to work for custom font directories too, but I have no idea how to reproduce this.

The other major NX annoyance I run into is clients that either don’t start when they’re supposed to, or whose windows never appear when the session resumes. In the former case, sometimes the initial client I ask NX to run (a small rxvt) never starts, but the NX session is up, so I can start another rxvt if I notice before NX destroys the session from a lack of clients. In the latter case, the clients are there, so for example I can use emacsclient -e '(new-frame)' then C-x 5 1 to rescue my Emacs session and close all the unavailable frames. I haven’t found a more general fix for this one.

Random bonus for anyone who doesn’t follow my Twitter stream: ggplot2 is an amazingly well done plotting package. Having spent quality time with Jgraph, PyChart, matplotlib, Mathematica, Excel, Numbers, etc. I’ve never found one that did what I wanted as quickly. Highly recommended.

One comment on “Fonts and NX”

  1. 25 January 2009 | 9:30 PM

    Thanks for the kind words about ggplot2 :)

Leave a reply