One of the things that has bugged me about some of the supplied tools that come with SWI Prolog is the fonts; some people might like them, I tolerated them for a long long time but in the back of my mind I was always wanting to figure out how to change them to something that I liked more than the defaults.
Today I changed them.
It wasn’t easy either, I have the latest GitHub build of SWI on my machine and I pull and rebuild every few days just because I can. The reason I decided to get the source code was because of the new dark theme in the editor. I hear you… you mean it doesn’t have themes? Well, for historical reasons, it doesn’t. But it kind of does have light and dark now in the latest build.
Last week or so I submitted a small patch because the colour combination for the DCG push-back rule meant that you couldn’t see the actual text content, here’s what I mean, my patch is the one on the right in this screen grab comparison.
Flush with the success of that, I tracked down the font handling code in xfont.c in the source, I am on Linux Mint and so that file was in the x11 folder as usual.
After much faffing around and with some cracking input from the as-ever brilliant forum (as usual), in this particular instance from Jan Wielemaker (SWI-s creator no less) I eventually found the secret sauce to change all of the fonts used in the IDE and the supporting tools.
Here is the bottom part of my
~/.config/swipl/xpce/Defaults file, the part that specifies the screen fonts. It turns out that there is a 4 argument version of
font() as well, if that version is used, the first three parameters are effectively ignored, serving only as unused meta-information.
display.system_fonts: [ \ normal := font(helvetica, roman, 12, 'Ubuntu-12:regular'), \ bold := font(helvetica, bold, 12, 'Ubuntu-12:bold'), \ italic := font(helvetica, oblique, 12, 'Ubuntu-12:italic'), \ small := font(helvetica, roman, 10, 'Ubuntu-10:narrow'), \ large := font(helvetica, roman, 14, 'Ubuntu-14:regular'), \ boldlarge := font(helvetica, bold, 14, 'Ubuntu-14:bold'), \ huge := font(helvetica, roman, 18, 'Ubuntu-18:regular'), \ boldhuge := font(helvetica, bold, 18, 'Ubuntu-1:bold'), \ fixed := font(screen, roman, 14, 'IBM 3270-16:narrow'), \ tt := font(screen, roman, 14, 'IBM 3270-16:narrow'), \ boldtt := font(screen, bold, 14, 'IBM 3270-16:narrow,bold') \ ]
And of course here is the obligatory screenshot of me hacking away at FELT, my computer language, with all the power of SWI Prolog at my fingertips. May the force be with you.
NOTES: If you use this method, when you increase the font with
Ctrl-+, the font reverts to the stock one at the new size…there is work to be done but I never used that feature. Also, the font scaling option has no effect either.