Fixing Windows CMD Font Issue

10/22/2018


Problem

One day, I suddenly found out that the font in my Windows command (CMD) was changed by something into a bad-looking non-monospace font somehow.

font

The same thing happened to my Powershell since they share the same profile.

font

Such a bad-looking font was definitely unacceptable by a heavy command line user. So, it must be fixed. Normally, I could change the font by right-clicking the title bar, selecting properties-Font. However, it didn’t work this time since the fonts I wanted were missing.

font

As the screenshot showed, the only available fonts were some Chinese fonts, which were useless in this case. So where did my programming fonts go?

Cause

By checking the list of available fonts, I found out that all of them were Chinese fonts. So it must have something to do with the code schema. By checking the Options tab in CMD properties, I was able to see the code page currently being used:

font

The code page was set as Simplified Chinese GBK. It happened because I just installed some Chinese software and changed the language of non-Unicode programs to simplified Chinese. In order to use my programming fonts, I had to change the code page to something like 65001 for UTF-8.

As the time of writing, I found two possible solutions:

Solution One

This solution worked on my Windows 10 version 1803 machine.

Open control panel, go to “Clock and Region” -> “Region”, open the dialogue box and switch to “Administrative” tab.

font

In “Language for non-Unicode programs”, click “Change system locale…”, in the next window, keep the language unchanged and check the “Beta: Use Unicode UTF-8 for world-wide language support”

Save the configuration and restart machine as requested. The CMD and Powershell should now use UTF-8 as default code page and all previous fonts should be ready for use.

font

This solution is very simple, but it’s in beta status and may cause some unexpected problems for some non-Unicode programs. If it doesn’t work very well, there’s another solution:

Solution Two

After the CMD or Powershell is opened, run the following command in CMD:

chcp 65001

This changes the code page to UTF-8. Open the font setting page again, this time, all previous fonts are listed.

However, this solution is just temporary. It works only for the current CMD instance. The next CMD opened still has the same problem and it would be very inconvenient if I have to run the same command every time I run CMD or Powershell.

To fix the issue once and for all, open registry path

HKLM:\SOFTWARE\Microsoft\Command Processor

add or edit a string value called Autorun, then set the value to

chcp 65001 > nul

The CMD will now switch the code page automatically when run each time.

Either way, after changing the code page and font, the CMD should look normal again:

font

Back to Top

SYANG.IO © 2021