Fix xfig's font problems on Windows (Cygwin)
Xfig is still a very convenient tool for me, and I need it to work under Cygwin. I've tried to document how I've been able to get it to work. You will, of course, need to start by installing Cygwin.
Download setup-x86.exe
Download the 32-bit (or 64-bit if you're feeling lucky) setup.exe from cygwin.com. I like to copy it to my Windows desktop so I can easily run it again when I need to add packages. The 64-bit version seemed to be missing a few packages the last time I tried it, and I haven't tried it since then.
Run the installer
Select install from internet
. The default installation directory
(C:\cygwin
) works for me. I also like to store package information
to C:\cygstore
, but this isn't important. After selecting file
locations, you can use the
mirror sites page to find a local
mirror.
Choose these packages for installation:
- xorg-server
- xinit
- xfig
- xfig-lib
- ghostscript
- ghostscript-fonts-other
- ghostscript-fonts-std
...and then Cygwin will decide which dependencies will also need to be installed. The initial installation takes me about 15 minutes.
Start the Cygwin Terminal
This creates your home directory and some useful configuration files.
Start the X server
Starting the X server with
export DISPLAY=:0
startxwin &
...will let you keep using the same terminal after the server starts.
I've had some strange problems with this sequence of commands -- it
works for me on a host OS, but it failed at first on a VirtualBox
Windows 7 guest. The fix was to start the XWin Server
via the start
menu instead of the command line. After I did that, the command line
started working. Maybe a config file got written? Anyway, now X is
running.
Start xfig to see the problem
I've got xfig 3.2 patchlevel 5c. I add some text to the canvas, then zoom in. The error message is:
Font size 17 not found, using smaller 12 point
...and the glyphs don't scale with the rest of the canvas -- extremely annoying.
Install some font tools
I needed to install the:
- xset
- mkfontdir
- mkfontscale
...packages via the cygwin installer.
Download ghostscript fonts
I'm not sure where the fonts should be archived, but the file you want
is ghostscript-fonts-std-8.11.tar.gz
. It looks like it's hosted
at SourceForge. I make the directory ~/fonts
and unpack the file
there. This will make its own fonts
directory. Descend into this
directory and:
mkfontdir
mkfontscale
Add this new fonts directory to the list known by X
With the X server running,
xset fp+ ~/fonts/fonts
...and you won't see any output.
Test the fix
Fire up xfig again and type some text. Enjoy the nice scaling glyphs when you change the zoom factor!
You'll probably want to add the export DISPLAY=:0
line to your
.bash_profile
or your .bashrc
file. Unfortunately, the xset
command won't work until X is actually running. You could add that
line to your .bashrc
, but you'd have to make sure you started
X via the start menu before you started the Cygwin Terminal. You
could also simply type bash
after starting X to re-run the .bashrc
commands. And there are probably many better ways of doing all this.
Update on 2021-Jan-20 — Cygwin's X server issues
I stopped using Cygwin's X server because it wasn't working well with my high resolution display. Xfig's buttons and popups were too tiny to be usable. The VcXsrv server does a much better job, but my xset
command stopped working. I saw the error messages:
xset: bad font path element (#97), possible causes are:
Directory does not exist or has wrong permissions
Directory missing fonts.dir
Incorrect font server address or syntax
The fix was to replace the Cygwin file path with a Windows path:
xset fp+ "c:/cygwin64/home/me/fonts/fonts"
...where c:/cygwin64/home/me
is my home directory.