The Command Prompt and Fonts

In Windows Command Shells, I wrote about about the Command Prompt’s inability to handle Unicode. I noted that this problem was really with the infrastructure behind the Command Prompt, so other console programs that use the same infrastructure have the same problem.

That’s not really true. If I send UTF-8 octets to the terminal, they get there intact. I can redirect the output to a file then look at it in an appropriate editor to see the correct data.

The problem is that the terminal can’t display the characters, for reasons that Raymond Chen writes about in Why are console windows limited to Lucida Console and raster fonts?. The right data are there, but the fonts to display them don’t have the glyphs.

The Command Prompt doesn’t have a way to add fonts to it’s list of available fonts. No matter how many fonts you install in Windows, that list in Properties will be the same.

However, you can use regedit to change that list. You have to change or add a string value under \HKEY_LOCAL_MACHINE
SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont
.

The name has to be a series of zeroes. I don’t know why. The font name has to be the name shown in the \HKEY_LOCAL_MACHINE
SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts
. The White Rabbit font works.

Now the console properties shows the new font.

I haven’t found a way to tell which fonts will work before going through all of those steps. Microsoft has four requirements for a TrueType font for the console.

  • Not italic
  • Can’t have negative A or C space, which means it can’t stick out of it’s box to either the left or right. The A and C space is the padding inside the box, and negative space means there’s some overflow.
  • Must be FF_MODERN if it’s TrueType. I don’t know which bit of the TrueType properties this looks at. I think you can write a C++ program using the Windows API to check this.
  • Must be OEM_CHARSET if it’s not TrueType. I don’t know how you get this from a font.

The White Rabbit font meets all of these requirements, but that doesn’t matter. It still doesn’t have the glyphs I’d want. That leaves me where I started. Almost all consoles on Windows are inadequate until someone makes a font with the right properties.

Further reading

Leave a Reply

Your email address will not be published. Required fields are marked *