3

After going blind from using Gvim with non-bitmapped fonts, I tried to narrow my question from the previous attempts (1) and (2) (with older attempts going back years). Specifically, I wanted to find a means to force visibility of X11 fonts to Gvim. This X11 font info page explains that I need bitmapped fonts to avoid the horrible mixing of brightness from adjacent (logical) pixels, and even identifies the font directories.

Unfortunately, Gvim doesn't recognize such fonts. For example, my xterm can be set to (say) -misc-fixed-medium-r-normal--13-120-75-75-c-80-iso8859-1, but if I set Gvim's guifont to this, it just defaults to the same spaced-out font that it does when supplied with an unrecognized font specification.

Web search indicates that one reason why the fonts may not be visible to Gvim is that the host folder is not in the "font path". X11 fonts are so complicated that I could not find out how to display the font path (I can set it using xset). Further web search says that it is set in an xorg.conf file, but a find command issued for xorg.conf* yields nothing (an Ubuntu page suggested possible path /etc/X11/xorg.conf). Further search unearths frequent mention that xorg.conf is no longer used these days.

Since I'm using Cygwin, I fortunately found a font page indicating that the font path is set in /etc/X11/fontpath.d/. At last, something that actually rings true in my system:

$ ls -l /etc/X11/fontpath.d/ | sed -e 's/.*[0-9][0-9]:[0-9][0-9] //'
total 5
terminus:unscaled -> /usr/share/fonts/terminus/
xorg-x11-fonts-100dpi:unscaled:pri=30 -> /usr/share/X11/fonts/100dpi/
xorg-x11-fonts-75dpi:unscaled:pri=20 -> /usr/share/X11/fonts/75dpi/
xorg-x11-fonts-misc:unscaled:pri=10 -> /usr/share/X11/fonts/misc/
xorg-x11-fonts-Type1 -> /usr/share/X11/fonts/Type1/

I've unsuccessfully tried to peek into the files therein before, but I'm not sure if that would actually help. What the above shows is that the idea of X11 bitmapped fonts in the font path is satisfied, and the reason why Gvim can't see them must be some other reason. This is a problem that is very specific to Gvim, and I have thus far been unable to find anything online for what determines the fonts that Gvim sees.

Gvim has been around for decades -- surely this is a well-known detail?

Helpful background found

This explanation of fontconfig fills in some of my void of knowledge. It tells me that I want to avoid Type 1 fonts. Using fc-list, I found that the "recognized" (registered?) fonts include those in the folder subtrees rooted in both /usr/share/fonts and/usr/share/X11/fonts. I am disturbed by the phrase "XFT allows scaling of the old bitmap fonts to look like Type1 fonts". Maybe that's why my fonts looks so bad, but it doesn't explain why this only afflicts Gvim.

This page on using bitmap fonts in Gvim is very relevant, but I have no /etc/fonts/conf.d/70-no-bitmaps.conf to remove and no /etc/fonts/conf.avail/70-yes-bitmaps.conf to link. Indeed, I have no /etc/fonts/conf.avail folder.

The above page is linked to by this page on activating bitmap fonts, but I don't have 70-force-bitmaps to link to either.

I also came across the suggestion to set the antialias option, but in my Gvim, that option is apparently not supported.

This Wikipedia page on computer fonts says that PCF is bitmap, and this Cygwin/Gvim page corroborates this in saying "You're better off using the PCF form of the font". However, its suggestion of such a font is :set gfn=LucidaTypewriter\ 17, which definitely doesn't look bitmapped, judging by the foreground/background color averaging on some pixels. It may be the case that the underlying font is bitmapped, but there's scaling/antialiasing occuring between the font itself and Gvim, possibly done by X.

The Fonts in X11R7.5 page contains an Installing fonts section. It contains a Troubleshooting subsection listing the extensions of bitmap fonts (and freetype fonts, which I'm not interested in right now):

  • "bitmap": bitmap fonts ('*.bdf', '*.pcf' and '*.snf');

  • "freetype": TrueType fonts ('*.ttf' and '*.ttc'), OpenType fonts ('*.otf' and '*.otc') and Type 1 fonts ('*.pfa' and '*.pfb').

I found the extensions of files in the /usr/share/fonts /usr/share/X11/fonts file trees, taking care to preserve extensions of gzipped files:

find /usr/share/fonts/ /usr/share/X11/fonts/ -type f \
| sed -e 's=.*\(\.[[:alnum:]]\{1,3\}.gz\)$=\1=' \
      -e '/\.gz$/!s=.*\(\.[[:alnum:]]\{1,\}$\)=\1=' \
| sort -u | tr '\n' ' '

    .afm .alias .dir .enc.gz .otf .pcf.gz
    .pfa .pfb .scale .t1 .ttf .uuid

Comparing to the above bitmap and freetype file extensions above, we see that the only bitmap fonts have *.pcf extension. All the others are freetype, with exception of extensions *.afm, *.alias, *.dir, *.scale, and *.uuid. Based on the extensions alone, we can speculate that all these exceptions serve purpose other than housing actual fonts (well, perhaps *.afm looks like it may be a font).

The folders containing the identified bitmap fonts are:

find /usr/share/fonts/ /usr/share/X11/fonts/
    -type f -name '*.pcf.gz' \
| sed -e 's=/[^/]*$==' | sort -u

    /usr/share/fonts/terminus
    /usr/share/X11/fonts/100dpi
    /usr/share/X11/fonts/75dpi
    /usr/share/X11/fonts/misc

ls \
/usr/share/fonts/terminus \
/usr/share/X11/fonts/100dpi \
/usr/share/X11/fonts/75dpi \
/usr/share/X11/fonts/misc

The ls command shows that only the terminus folder contains fonts with a common filename root, e.g.,

/usr/share/fonts/terminus:
fonts.dir
fonts.scale
ter-112b.pcf.gz
ter-112n.pcf.gz
ter-114b.pcf.gz
<...etc...>

All the other folders contain a diversity of fonts with different font names. I was hoping that I can easily find bitmap font names matching those from :set guifont=*, but the only easily recognizable Gvim font name is terminus -- or rather, Terminus in the guifont picker. It seems to be free from the mixing of brightness between foregroound and background, indicating that not only is it a bitmap font, but that it also behaves like a bitmap font in Cygwin's X11. However, it is not a good looking font. :(

12
  • I think you should consider running the native Windows gvim and try to integrate it with Cygwin. Messing with X11 on Windows is likely to be quite frustrating I'd expect... See stackoverflow.com/q/12654100/9447571 for some ideas on how to use Windows gvim with cygwin. (Though that might not be enough... YMMV. Maybe you'll need more searches to get that integration going.) Also maybe look into WSL and WSL2 in Windows as possible replacements for Cygwin, I heard they're awesome and quite well integrated into Windows.
    – filbranden
    Mar 7 '20 at 22:14
  • I did that for years. It takes too much time trying to force it to work with bash and Cygwin unix utilities. Mar 7 '20 at 22:16
  • I wonder if you can build Vim from source inside Cygwin, but still enable Windows as the GUI toolkit... Googling didn't show useful results, but at least in theory I'd expect it might be possible to do it.
    – filbranden
    Mar 7 '20 at 22:19
  • I'm sure that it is possible, but not being a developer, it is beyond what I can achieve with the available time. It's really quite odd. I never would have imagined that the information about where Gvim finds its fonts would be so elusive. Unless it's not configurable, i.e., is a parameter specified when it is compiled. That is not what I would expect from an X-windows client Mar 7 '20 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.